Skip to content

Commit

Permalink
Don't allow to open disassemble view on symbols without needed info
Browse files Browse the repository at this point in the history
It's useless to offer the user the ability to open the disassembly
view on symbols without the required info - disable the actions
early to indicate that state.

Fixes: KDAB#536
  • Loading branch information
milianw committed Oct 29, 2023
1 parent 6fa2487 commit 5d5df76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/flamegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,12 @@ bool FlameGraph::eventFilter(QObject* object, QEvent* event)
[this, item]() { emit jumpToCallerCallee(item->symbol()); });
auto* openEditorAction = contextMenu.addAction(tr("Open in Editor"));
connect(openEditorAction, &QAction::triggered, this, [this, item]() { emit openEditor(item->symbol()); });
openEditorAction->setEnabled(item->symbol().isValid());
contextMenu.addSeparator();
auto* viewDisassembly = contextMenu.addAction(tr("Disassembly"));
connect(viewDisassembly, &QAction::triggered, this,
[this, item]() { emit jumpToDisassembly(item->symbol()); });
viewDisassembly->setEnabled(item->symbol().canDisassemble());

auto* copy = contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy"));
connect(copy, &QAction::triggered, this, [item]() { qApp->clipboard()->setText(item->description()); });
Expand Down
5 changes: 5 additions & 0 deletions src/models/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ struct Symbol
{
return !symbol.isEmpty() || !binary.isEmpty() || !path.isEmpty();
}

bool canDisassemble() const
{
return !symbol.isEmpty() && !path.isEmpty() && relAddr > 0 && size > 0;
}
};

QDebug operator<<(QDebug stream, const Symbol& symbol);
Expand Down
1 change: 1 addition & 0 deletions src/resultsutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void setupContextMenu(QTreeView* view, CostContextMenu* costContextMenu, int sym
auto* viewDisassembly = contextMenu.addAction(QCoreApplication::translate("Util", "Disassembly"));
QObject::connect(viewDisassembly, &QAction::triggered, &contextMenu,
[symbol, callback]() { callback(CallbackAction::ViewDisassembly, symbol); });
viewDisassembly->setEnabled(symbol.canDisassemble());
}
contextMenu.addSeparator();
costContextMenu->addToMenu(view->header(),
Expand Down

0 comments on commit 5d5df76

Please sign in to comment.