Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error message when exporting a flamegraph that hasn't been opened #588

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/flamegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,8 @@ void FlameGraph::setData(FrameGraphicsItem* rootItem)
if (isVisible()) {
selectItem(m_rootItem);
}

emit canConvertToImageChanged();
}

void FlameGraph::selectItem(int item)
Expand Down Expand Up @@ -1238,3 +1240,8 @@ void FlameGraph::updateNavigationActions()
m_forwardAction->setEnabled(isNotLastItem);
m_resetAction->setEnabled(hasItems);
}

bool FlameGraph::canConvertToImage() const
{
return m_rootItem != nullptr;
}
2 changes: 2 additions & 0 deletions src/flamegraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FlameGraph : public QWidget

QImage toImage() const;
void saveSvg(const QString& fileName) const;
bool canConvertToImage() const;

protected:
bool eventFilter(QObject* object, QEvent* event) override;
Expand All @@ -55,6 +56,7 @@ private slots:
void selectStack(const QVector<Data::Symbol>& stack, bool bottomUp);
void jumpToDisassembly(const Data::Symbol& symbol);
void uiResetRequested();
void canConvertToImageChanged();

private:
void setTooltipItem(const FrameGraphicsItem* item);
Expand Down
5 changes: 5 additions & 0 deletions src/resultsflamegraphpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ ResultsFlameGraphPage::ResultsFlameGraphPage(FilterAndZoomStack* filterStack, Pe
connect(parser, &PerfParser::bottomUpDataAvailable, this, [this, exportMenu](const Data::BottomUpResults& data) {
ui->flameGraph->setBottomUpData(data);
m_exportAction = exportMenu->addAction(QIcon::fromTheme(QStringLiteral("image-x-generic")), tr("Flamegraph"));
m_exportAction->setEnabled(ui->flameGraph->canConvertToImage());

connect(ui->flameGraph, &FlameGraph::canConvertToImageChanged, m_exportAction,
[this] { m_exportAction->setEnabled(ui->flameGraph->canConvertToImage()); });

connect(m_exportAction, &QAction::triggered, this, [this]() {
const auto filter = tr("Images (%1);;SVG (*.svg)").arg(imageFormatFilter());
QString selectedFilter;
Expand Down
Loading