#include <QDebug>
#include <QAction>
+#include <ThreadWeaver/ThreadWeaver>
#include <KLocalizedString>
#include <KColorScheme>
bool m_isHovered;
};
+Q_DECLARE_METATYPE(FrameGraphicsItem*);
+
FrameGraphicsItem::FrameGraphicsItem(const quint64 cost, const QString& function, FrameGraphicsItem* parent)
: QGraphicsRectItem(parent)
, m_cost(cost)
, m_selectedItem(nullptr)
, m_minRootWidth(0)
{
+ qRegisterMetaType<FrameGraphicsItem*>();
+
setLayout(new QVBoxLayout);
m_scene->setItemIndexMethod(QGraphicsScene::NoIndex);
void FlameGraph::showData()
{
setData(nullptr);
- setData(parseData(m_showBottomUpData ? m_bottomUpData : m_topDownData));
+
+ using namespace ThreadWeaver;
+ auto data = m_showBottomUpData ? m_bottomUpData : m_topDownData;
+ stream() << make_job([data, this]() {
+ auto parsedData = parseData(data);
+ QMetaObject::invokeMethod(this, "setData", Qt::QueuedConnection,
+ Q_ARG(FrameGraphicsItem*, parsedData));
+ });
}
void FlameGraph::setData(FrameGraphicsItem* rootItem)
m_rootItem = rootItem;
m_selectedItem = rootItem;
if (!rootItem) {
+ auto text = m_scene->addText(i18n("generating flame graph..."));
+ m_view->centerOn(text);
return;
}
protected:
bool eventFilter(QObject* object, QEvent* event) override;
+private slots:
+ void setData(FrameGraphicsItem* rootItem);
+
private:
void showData();
- void setData(FrameGraphicsItem* rootItem);
void selectItem(FrameGraphicsItem* item);
TreeData m_topDownData;