From 0012ace6ba03e5c275065c811305bdfc42d3a5fb Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Tue, 4 Aug 2015 22:52:26 +0530 Subject: [PATCH 1/9] everything going in stacked widget now --- rbkit-lib/CMakeLists.txt | 2 ++ rbkit-lib/ui/appmainwindow.cpp | 14 ++++++++++++-- rbkit-lib/ui/appmainwindow.h | 7 ++++++- rbkit-lib/ui/centralwidget.cpp | 10 +++++----- rbkit-lib/ui/centralwidget.h | 5 +++-- rbkit-lib/ui/stackedwidget.cpp | 8 ++++++++ rbkit-lib/ui/stackedwidget.h | 14 ++++++++++++++ 7 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 rbkit-lib/ui/stackedwidget.cpp create mode 100644 rbkit-lib/ui/stackedwidget.h diff --git a/rbkit-lib/CMakeLists.txt b/rbkit-lib/CMakeLists.txt index 6dd725a..85dfc73 100644 --- a/rbkit-lib/CMakeLists.txt +++ b/rbkit-lib/CMakeLists.txt @@ -67,6 +67,7 @@ add_library(rbkit ui/centralwidget.cpp ui/ribbontoolbar.cpp ui/cpuview.cpp + ui/stackedwidget.cpp model/cpunode.cpp model/cpuprof.cpp model/cpustorage.cpp @@ -104,6 +105,7 @@ add_library(rbkit ui/centralwidget.h ui/ribbontoolbar.h ui/cpuview.h + ui/stackedwidget.h layoututil.hpp common.h diff --git a/rbkit-lib/ui/appmainwindow.cpp b/rbkit-lib/ui/appmainwindow.cpp index bbe7d55..f973b6e 100644 --- a/rbkit-lib/ui/appmainwindow.cpp +++ b/rbkit-lib/ui/appmainwindow.cpp @@ -8,8 +8,14 @@ AppMainwindow::AppMainwindow(QWidget *parent) : QMainWindow(parent) { - centralWidget = new CentralWidget(this); - setCentralWidget(centralWidget); + stackedWidget = new StackedWidget(this); + setCentralWidget(stackedWidget); + + centralMemoryWidget = new CentralWidget(stackedWidget); + //setCentralWidget(centralWidget); + int index = stackedWidget->addWidget(centralMemoryWidget); + + stackedWidget->setCurrentIndex(index); appStatusBar = new QStatusBar(this); setStatusBar(appStatusBar); @@ -36,3 +42,7 @@ AppMainwindow::~AppMainwindow() delete centralWidget; } +void AppMainwindow::tabChanged(int tab) +{ + stackedWidget->setCurrentIndex(tab); +} diff --git a/rbkit-lib/ui/appmainwindow.h b/rbkit-lib/ui/appmainwindow.h index e8377ae..2451cfb 100644 --- a/rbkit-lib/ui/appmainwindow.h +++ b/rbkit-lib/ui/appmainwindow.h @@ -2,16 +2,20 @@ #define APPMAINWINDOW_H #include +#include "stackedwidget.h" #include "centralwidget.h" class QStatusBar; class QLabel; class QProgressBar; +class StackedWidget; class AppMainwindow : public QMainWindow { Q_OBJECT - CentralWidget *centralWidget; + StackedWidget *stackedWidget; + CentralWidget *centralMemoryWidget; + CentralWidget *centralCpuWidget; QLabel *statusLabel; public: @@ -23,6 +27,7 @@ class AppMainwindow : public QMainWindow signals: public slots: + void tabChanged(int); }; #endif // APPMAINWINDOW_H diff --git a/rbkit-lib/ui/centralwidget.cpp b/rbkit-lib/ui/centralwidget.cpp index 367728c..fdfe5ac 100644 --- a/rbkit-lib/ui/centralwidget.cpp +++ b/rbkit-lib/ui/centralwidget.cpp @@ -89,7 +89,7 @@ void CentralWidget::objectDumpAvailable(int snapshotVersion) QString snapshotName = QString("Heap Dump #%0").arg(snapshotVersion); snapshotState->addNewSnapshot(heapUI, snapshotName); showStatusMessage("Heap snapshot complete"); - mainWindow->appStatusBar->clearMessage(); + //mainWindow->appStatusBar->clearMessage(); setProgressBarValue(100); snapshotProgressTimer->stop(); snapshotState->setSnapshotProgress(false); @@ -129,7 +129,7 @@ QList CentralWidget::diffableSnapshotVersions() return snapshotState->diffableSnapshotVersions(); } -CentralWidget::CentralWidget(AppMainwindow *window) : QWidget(window) +CentralWidget::CentralWidget(QStackedWidget *window) : QWidget(window) , mainWindow(window) { mainLayout = new QVBoxLayout(); @@ -191,17 +191,17 @@ void CentralWidget::newCpuView() void CentralWidget::showStatusMessage(const QString &message) const { - mainWindow->appStatusBar->showMessage(message); + //mainWindow->appStatusBar->showMessage(message); } void CentralWidget::setProgressBarValue(int value) const { - mainWindow->progressBar->setValue(value); + //mainWindow->progressBar->setValue(value); } void CentralWidget::resetProgressBar() const { - mainWindow->progressBar->reset(); + //mainWindow->progressBar->reset(); } bool CentralWidget::attemptMemorySnapshot() diff --git a/rbkit-lib/ui/centralwidget.h b/rbkit-lib/ui/centralwidget.h index 85e250a..5cebf39 100644 --- a/rbkit-lib/ui/centralwidget.h +++ b/rbkit-lib/ui/centralwidget.h @@ -18,6 +18,7 @@ class HeapDumpForm; #include "memoryview.h" #include "model/snapshotstate.h" #include "cpuview.h" +#include class CentralWidget : public QWidget @@ -28,13 +29,13 @@ class CentralWidget : public QWidget QSharedPointer chartingTab; QSharedPointer memoryView; QHash> cpuViewHash; - AppMainwindow *mainWindow; + QStackedWidget *mainWindow; RBKit::SnapshotState *snapshotState; QTimer *snapshotProgressTimer; QList diffableSnapshotVersions(); public: - explicit CentralWidget(AppMainwindow *mainWindow); + explicit CentralWidget(QStackedWidget *mainWindow); ~CentralWidget(); void setupCentralView(); void showStatusMessage(const QString &message) const; diff --git a/rbkit-lib/ui/stackedwidget.cpp b/rbkit-lib/ui/stackedwidget.cpp new file mode 100644 index 0000000..50dd894 --- /dev/null +++ b/rbkit-lib/ui/stackedwidget.cpp @@ -0,0 +1,8 @@ +#include "stackedwidget.h" + +StackedWidget::StackedWidget(AppMainwindow *mainWindow) + : QStackedWidget(mainWindow) +{ + +} + diff --git a/rbkit-lib/ui/stackedwidget.h b/rbkit-lib/ui/stackedwidget.h new file mode 100644 index 0000000..288ee27 --- /dev/null +++ b/rbkit-lib/ui/stackedwidget.h @@ -0,0 +1,14 @@ +#ifndef STACKEDWIDGET_H +#define STACKEDWIDGET_H +#include +#include "appmainwindow.h" + +class AppMainwindow; + +class StackedWidget : public QStackedWidget +{ +public: + explicit StackedWidget(AppMainwindow* mainWindow); +}; + +#endif // STACKEDWIDGET_H From 9e485e522572858af30265912504456324d5c539 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Wed, 5 Aug 2015 11:12:31 +0530 Subject: [PATCH 2/9] added central widget to two pages of stackedwidget --- rbkit-lib/ui/appmainwindow.cpp | 7 +++++-- rbkit-lib/ui/centralwidget.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rbkit-lib/ui/appmainwindow.cpp b/rbkit-lib/ui/appmainwindow.cpp index f973b6e..c3bf73f 100644 --- a/rbkit-lib/ui/appmainwindow.cpp +++ b/rbkit-lib/ui/appmainwindow.cpp @@ -13,7 +13,10 @@ AppMainwindow::AppMainwindow(QWidget *parent) : QMainWindow(parent) centralMemoryWidget = new CentralWidget(stackedWidget); //setCentralWidget(centralWidget); - int index = stackedWidget->addWidget(centralMemoryWidget); + stackedWidget->addWidget(centralMemoryWidget); + + centralCpuWidget = new CentralWidget(stackedWidget); + int index = stackedWidget->addWidget(centralCpuWidget); stackedWidget->setCurrentIndex(index); @@ -39,7 +42,7 @@ AppMainwindow::AppMainwindow(QWidget *parent) : QMainWindow(parent) AppMainwindow::~AppMainwindow() { - delete centralWidget; + delete centralMemoryWidget; } void AppMainwindow::tabChanged(int tab) diff --git a/rbkit-lib/ui/centralwidget.cpp b/rbkit-lib/ui/centralwidget.cpp index fdfe5ac..6af782b 100644 --- a/rbkit-lib/ui/centralwidget.cpp +++ b/rbkit-lib/ui/centralwidget.cpp @@ -154,7 +154,7 @@ CentralWidget::CentralWidget(QStackedWidget *window) : QWidget(window) disableCloseButtonOnFirstTab(chartingTab.data()); makeMarginSpacingZero(mainLayout); setLayout(mainLayout); - actionToolBar->disableProfileActions(); + //actionToolBar->disableProfileActions(); } CentralWidget::~CentralWidget() From fae9271c07502bbef095634f726eee7448d1d0b0 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Wed, 5 Aug 2015 16:01:29 +0530 Subject: [PATCH 3/9] cpuview working inside the stacked widget qlist holding cpuviewptr's works fine --- rbkit-lib/ui/actiontoolbar.cpp | 14 +++++++-- rbkit-lib/ui/actiontoolbar.h | 8 ++++- rbkit-lib/ui/appmainwindow.cpp | 56 +++++++++++++++++++++++++++++----- rbkit-lib/ui/appmainwindow.h | 12 +++++++- rbkit-lib/ui/centralwidget.cpp | 7 ----- rbkit-lib/ui/centralwidget.h | 1 + rbkit-lib/ui/cpuview.cpp | 1 + rbkit-lib/ui/cpuview.h | 1 + rbkit-lib/ui/ribbontoolbar.cpp | 2 ++ rbkit-lib/ui/ribbontoolbar.h | 2 +- rbkit-lib/ui/stackedwidget.cpp | 1 - 11 files changed, 83 insertions(+), 22 deletions(-) diff --git a/rbkit-lib/ui/actiontoolbar.cpp b/rbkit-lib/ui/actiontoolbar.cpp index 14d6b7a..f608dea 100644 --- a/rbkit-lib/ui/actiontoolbar.cpp +++ b/rbkit-lib/ui/actiontoolbar.cpp @@ -26,8 +26,8 @@ static void toggleConnectButtonState(ConnectionStates state, QToolButton *btn) { } } -ActionToolbar::ActionToolbar(CentralWidget *widget) - : centralWidget(widget) +ActionToolbar::ActionToolbar(AppMainwindow *window, CentralWidget *widget) + : centralWidget(widget), window(window) { Q_INIT_RESOURCE(tool_icons); connectionState = DISCONNECTED; @@ -157,7 +157,7 @@ void ActionToolbar::setupToolBar() QIcon(":/icons/Compare-32.png"), "cpu_profiling"); connect(stopCPUButton, &QToolButton::clicked, this, &ActionToolbar::performStopCPUAction); - connect(this, SIGNAL(stopCPUProfiling()), centralWidget, SLOT(newCpuView())); + connect(this, SIGNAL(stopCPUProfiling()), window, SLOT(newCpuView())); toolBar->loadStyleSheet(":/icons/style.css"); } @@ -222,3 +222,11 @@ void ActionToolbar::disconnectedFromSocket() centralWidget->appDisconnected(); disableProfileActions(); } + +void ActionToolbar::connectTabChangedSignal(AppMainwindow *window) +{ + connect(toolBar, + SIGNAL(changeTab(int)), + window, + SLOT(tabChanged(int))); +} diff --git a/rbkit-lib/ui/actiontoolbar.h b/rbkit-lib/ui/actiontoolbar.h index 47edbac..a1dc652 100644 --- a/rbkit-lib/ui/actiontoolbar.h +++ b/rbkit-lib/ui/actiontoolbar.h @@ -12,10 +12,14 @@ #include "subscriber.h" #include "common.h" #include "memoryview.h" +#include "appmainwindow.h" +#include "stackedwidget.h" class QToolButton; class CentralWidget; class QTimer; +class AppMainwindow; +class StackedWidget; enum ConnectionStates { DISCONNECTED = 0, @@ -35,8 +39,9 @@ class ActionToolbar : public QObject Subscriber *subscriber; ConnectionStates connectionState; QThread subscriberThread; + AppMainwindow *window; public: - explicit ActionToolbar(CentralWidget *widget); + explicit ActionToolbar(AppMainwindow *window , CentralWidget *widget); void enableProfileActions(); void disableProfileActions(); void setupToolBar(); @@ -46,6 +51,7 @@ class ActionToolbar : public QObject RBKit::MemoryView *memoryView() const; void disconnectFromSocket(); void shutDownApp(); + void connectTabChangedSignal(AppMainwindow *window); private: QToolButton *gcButton; diff --git a/rbkit-lib/ui/appmainwindow.cpp b/rbkit-lib/ui/appmainwindow.cpp index c3bf73f..a68b8ca 100644 --- a/rbkit-lib/ui/appmainwindow.cpp +++ b/rbkit-lib/ui/appmainwindow.cpp @@ -8,18 +8,37 @@ AppMainwindow::AppMainwindow(QWidget *parent) : QMainWindow(parent) { + QWidget *mainWidget = new QWidget(this); + + mainLayout = new QVBoxLayout(); + stackedWidget = new StackedWidget(this); - setCentralWidget(stackedWidget); + setCentralWidget(mainWidget); centralMemoryWidget = new CentralWidget(stackedWidget); - //setCentralWidget(centralWidget); - stackedWidget->addWidget(centralMemoryWidget); + int index = stackedWidget->addWidget(centralMemoryWidget); + + actionToolBar = QSharedPointer::create(this, centralMemoryWidget); + + cpuTab = new QTabWidget(stackedWidget); + cpuTab->setTabsClosable(true); + connect(cpuTab, + SIGNAL(tabCloseRequested(int)), + this, + SLOT(closeCpuTab(int))); - centralCpuWidget = new CentralWidget(stackedWidget); - int index = stackedWidget->addWidget(centralCpuWidget); + stackedWidget->addWidget(cpuTab); stackedWidget->setCurrentIndex(index); + actionToolBar.data()->connectTabChangedSignal(this); + + mainLayout->addWidget(actionToolBar.data()->getToolBar(), 0, Qt::AlignTop); + mainLayout->addWidget(stackedWidget, 1); + + mainWidget->setLayout(mainLayout); + mainWidget->show(); + appStatusBar = new QStatusBar(this); setStatusBar(appStatusBar); @@ -35,10 +54,25 @@ AppMainwindow::AppMainwindow(QWidget *parent) : QMainWindow(parent) qRegisterMetaType(); } -/*CpuViewPtr AppMainwindow::getCpuView() +void AppMainwindow::newCpuView() { - return centralWidget->getCpuViewPtr(); -}*/ + QSharedPointer cpuView(new CpuView()); + cpuTab->addTab(cpuView.data(), "Cpu Tree"); + cpuViewList.append(cpuView); + + connect(cpuView.data(), + SIGNAL(fillCallGraph(QStandardItemModel*)), + RBKit::CpuStorage::getStorage().data(), + SLOT(fillCallGraphModel(QStandardItemModel*))); + + connect(cpuView.data(), + SIGNAL(fillFlatProfile(QStandardItemModel*)), + RBKit::CpuStorage::getStorage().data(), + SLOT(fillFlatProfileModel(QStandardItemModel*))); + + emit cpuView.data()->fillCallGraph(cpuView->callGraphModel); + emit cpuView.data()->fillFlatProfile(cpuView->flatGraphModel); +} AppMainwindow::~AppMainwindow() { @@ -49,3 +83,9 @@ void AppMainwindow::tabChanged(int tab) { stackedWidget->setCurrentIndex(tab); } + +void AppMainwindow::closeCpuTab(int index) +{ + cpuTab->removeTab(index); + cpuViewList.removeAt(index); +} diff --git a/rbkit-lib/ui/appmainwindow.h b/rbkit-lib/ui/appmainwindow.h index 2451cfb..a0c3423 100644 --- a/rbkit-lib/ui/appmainwindow.h +++ b/rbkit-lib/ui/appmainwindow.h @@ -4,20 +4,28 @@ #include #include "stackedwidget.h" #include "centralwidget.h" +#include "actiontoolbar.h" +#include "cpuview.h" class QStatusBar; class QLabel; class QProgressBar; class StackedWidget; +class ActionToolbar; class AppMainwindow : public QMainWindow { Q_OBJECT StackedWidget *stackedWidget; CentralWidget *centralMemoryWidget; - CentralWidget *centralCpuWidget; + QTabWidget *cpuTab; QLabel *statusLabel; + QSharedPointer actionToolBar; + QVBoxLayout *mainLayout; + + QList> cpuViewList; + public: explicit AppMainwindow(QWidget *parent = 0); ~AppMainwindow(); @@ -28,6 +36,8 @@ class AppMainwindow : public QMainWindow public slots: void tabChanged(int); + void newCpuView(); + void closeCpuTab(int); }; #endif // APPMAINWINDOW_H diff --git a/rbkit-lib/ui/centralwidget.cpp b/rbkit-lib/ui/centralwidget.cpp index 6af782b..2e94dbf 100644 --- a/rbkit-lib/ui/centralwidget.cpp +++ b/rbkit-lib/ui/centralwidget.cpp @@ -133,8 +133,6 @@ CentralWidget::CentralWidget(QStackedWidget *window) : QWidget(window) , mainWindow(window) { mainLayout = new QVBoxLayout(); - actionToolBar = QSharedPointer::create(this); - mainLayout->addWidget(actionToolBar->getToolBar(), 0, Qt::AlignTop); snapshotProgressTimer = new QTimer(this); snapshotState = new RBKit::SnapshotState(); @@ -222,8 +220,3 @@ bool CentralWidget::attemptMemorySnapshot() return true; } } - -/*CpuViewPtr CentralWidget::getCpuViewPtr() -{ - return cpuView; -}*/ diff --git a/rbkit-lib/ui/centralwidget.h b/rbkit-lib/ui/centralwidget.h index 5cebf39..25793cc 100644 --- a/rbkit-lib/ui/centralwidget.h +++ b/rbkit-lib/ui/centralwidget.h @@ -14,6 +14,7 @@ class QHBoxLayout; class QTabWidget; class AppMainwindow; class HeapDumpForm; +class ActionToolbar; #include "memoryview.h" #include "model/snapshotstate.h" diff --git a/rbkit-lib/ui/cpuview.cpp b/rbkit-lib/ui/cpuview.cpp index 3e469ec..1011acf 100644 --- a/rbkit-lib/ui/cpuview.cpp +++ b/rbkit-lib/ui/cpuview.cpp @@ -26,6 +26,7 @@ CpuView::CpuView(QWidget *parent) : CpuView::~CpuView() { + qDebug() << "**************deleting Cpu View*******************"; delete ui; } diff --git a/rbkit-lib/ui/cpuview.h b/rbkit-lib/ui/cpuview.h index 1dc80d2..4ec11bb 100644 --- a/rbkit-lib/ui/cpuview.h +++ b/rbkit-lib/ui/cpuview.h @@ -3,6 +3,7 @@ #include #include +//#include "appmainwindow.h" namespace Ui { class CpuView; diff --git a/rbkit-lib/ui/ribbontoolbar.cpp b/rbkit-lib/ui/ribbontoolbar.cpp index 89bea8e..84d8cf3 100644 --- a/rbkit-lib/ui/ribbontoolbar.cpp +++ b/rbkit-lib/ui/ribbontoolbar.cpp @@ -125,5 +125,7 @@ void RibbonToolBar::tabSelectionChanged(int index) containerData->hideWidget(layout1); } } + + emit changeTab(index); //for triggring the change in stacked widget } diff --git a/rbkit-lib/ui/ribbontoolbar.h b/rbkit-lib/ui/ribbontoolbar.h index a714064..8522626 100644 --- a/rbkit-lib/ui/ribbontoolbar.h +++ b/rbkit-lib/ui/ribbontoolbar.h @@ -66,7 +66,7 @@ class RibbonToolBar : public QWidget QToolButton* addRibbonAction(const QString &actionName, const QString &actionIdentifier, const QIcon &icon, const QString &tabIdentifier); signals: - + void changeTab(int index); //for triggring the change in stacked widget public slots: void tabSelectionChanged(int index); }; diff --git a/rbkit-lib/ui/stackedwidget.cpp b/rbkit-lib/ui/stackedwidget.cpp index 50dd894..5040b85 100644 --- a/rbkit-lib/ui/stackedwidget.cpp +++ b/rbkit-lib/ui/stackedwidget.cpp @@ -5,4 +5,3 @@ StackedWidget::StackedWidget(AppMainwindow *mainWindow) { } - From c5ea5294ba9dece275c72ca096d34c03c8234ed4 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Wed, 5 Aug 2015 16:03:16 +0530 Subject: [PATCH 4/9] removed some unwanted debugging code --- rbkit-lib/model/cpuprof.cpp | 15 --------------- rbkit-lib/model/cpuprof.h | 3 --- rbkit-lib/model/cpustorage.cpp | 24 ------------------------ rbkit-lib/model/cpustorage.h | 1 - 4 files changed, 43 deletions(-) diff --git a/rbkit-lib/model/cpuprof.cpp b/rbkit-lib/model/cpuprof.cpp index b9ad733..7c51258 100644 --- a/rbkit-lib/model/cpuprof.cpp +++ b/rbkit-lib/model/cpuprof.cpp @@ -29,7 +29,6 @@ void RBKit::CpuProf::parseFrames(QMap frames) void RBKit::CpuProf::decodeMap(QList > data) { for(int i = 0; i < data.size() ; i++) { - //qDebug() << data[i]; //detect starting of new frame parseFrames(data[i]); store()->incrementSampleCount(); @@ -37,17 +36,3 @@ void RBKit::CpuProf::decodeMap(QList > data) store()->updateSelfCount(); store()->clearFrameStack(); } - -void RBKit::CpuProf::startTraversals() -{ - qDebug() << "STARTING TRAVERSALS\n\n"; - //flatprofile traversal - //store()->traverseFlatProfile(); - - qDebug() << "\n\n Call Graph"; - //callgraph traversal - //store()->handleCallGraph(); - - //setting the default view as call graph - //store()->changeToCallGraph(); -} diff --git a/rbkit-lib/model/cpuprof.h b/rbkit-lib/model/cpuprof.h index 1c34092..aa97016 100644 --- a/rbkit-lib/model/cpuprof.h +++ b/rbkit-lib/model/cpuprof.h @@ -14,9 +14,6 @@ namespace RBKit void decodeMap(QList> data); void parseFrames(QMap frames); - //handeling traversals - void startTraversals(); - private: inline CpuStoragePtr store() { return CpuStorage::getStorage(); diff --git a/rbkit-lib/model/cpustorage.cpp b/rbkit-lib/model/cpustorage.cpp index a98a8d6..bcbb4f5 100644 --- a/rbkit-lib/model/cpustorage.cpp +++ b/rbkit-lib/model/cpustorage.cpp @@ -10,7 +10,6 @@ RBKit::CpuStorage::CpuStorage() void RBKit::CpuStorage::addNewNode(QMap data) { - //qDebug() << data; auto methodName = data[RBKit::ECeMethodName].toString(); RBKit::CpuNodePtr newNode( new RBKit::CpuNode(methodName, @@ -27,7 +26,6 @@ void RBKit::CpuStorage::addNewNode(QMap data) // increment total count newNode->incrementTotalCount(); - qDebug() << "----------incrementing total count------------"; //add to current frame stack if(currentStack.empty()) { @@ -53,10 +51,8 @@ bool RBKit::CpuStorage::exists(QVariant name) QString methodName = name.toString(); QHash::iterator iter = nodes.find(methodName); if(iter == nodes.end()) { - qDebug() << methodName << " does not exists"; return false; } else { - qDebug() << methodName << " exists"; return true; } } @@ -66,16 +62,8 @@ unsigned long long RBKit::CpuStorage::getSampleCount() return sample_count; } -void RBKit::CpuStorage::traverseNodes() -{ - for(QHash::iterator i = nodes.begin(); i != nodes.end(); i++) { - qDebug() << "" << *i.value(); - } -} - void RBKit::CpuStorage::clearFrameStack() { - qDebug() << "Reset Frame Stack"; currentStack.clear(); } @@ -84,8 +72,6 @@ void RBKit::CpuStorage::traverseFlatProfile(QStandardItem &fgRootNode) int indent; char space = ' '; for(QHash::iterator node = nodes.begin(); node != nodes.end(); node++) { - //qDebug() << "\n=====================\n"; - //qDebug() << "\n" + node.value()->getMethodName(); QList topLevelMethod = prepareRow(node.value()->getMethodName(), node.value()->getSelfCount(), @@ -95,15 +81,12 @@ void RBKit::CpuStorage::traverseFlatProfile(QStandardItem &fgRootNode) QList calledBy = node.value()->getCalledBy(); indent=4; foreach(RBKit::CpuNodePtr node, calledBy) { - //qDebug() << QString(indent, space) + node->getMethodName(); QList innerMethod = prepareRow(node->getMethodName(), node->getSelfCount(), node->getTotalCount()); topLevelMethod.first()->appendRow(innerMethod); } - //qDebug() << "\n=====================\n"; - //qDebug() << calledBy.size(); } } @@ -135,7 +118,6 @@ void RBKit::CpuStorage::updateExistingMethod(QMap data) //increment the method's total count nodes[methodName]->incrementTotalCount(); - qDebug() << "--------updating total count---------"; } void RBKit::CpuStorage::traverseCallGraph(RBKit::CpuNodePtr startingNode, @@ -146,7 +128,6 @@ void RBKit::CpuStorage::traverseCallGraph(RBKit::CpuNodePtr startingNode, QString methodName = startingNode->getMethodName(); if(!notReached.contains(methodName)) { - //qDebug() << QString(indent, space) + methodName; QList currentMethod = prepareRow(methodName, startingNode.data()->getSelfCount(), @@ -159,7 +140,6 @@ void RBKit::CpuStorage::traverseCallGraph(RBKit::CpuNodePtr startingNode, return; } else { - //qDebug() << QString(indent, space) + methodName; QList currentMethod = prepareRow(methodName, startingNode.data()->getSelfCount(), @@ -173,7 +153,6 @@ void RBKit::CpuStorage::traverseCallGraph(RBKit::CpuNodePtr startingNode, notReached.removeOne(startingNode->getMethodName()); foreach(RBKit::CpuNodePtr node, startingNode->getCalls()) { - //qDebug() << QString(indent,space) + node->getMethodName(); traverseCallGraph(node, cgRootNode, currentMethod.first()); } } @@ -189,7 +168,6 @@ QHash RBKit::CpuStorage::getNodes() void RBKit::CpuStorage::handleCallGraph(QStandardItem &cgRootNode) { notReached = nodes.keys(); - //qDebug() << notReached; while(!notReached.empty()) { CpuStorage::traverseCallGraph(nodes[notReached.front()], cgRootNode); } @@ -204,7 +182,6 @@ RBKit::CpuStoragePtr RBKit::CpuStorage::getStorage() void RBKit::CpuStorage::updateSelfCount() { if(!currentStack.isEmpty()) { - qDebug() << "-------updating self count--------"; QString lastMethod = currentStack.back(); nodes[lastMethod]->incrementSelfCount(); } @@ -238,7 +215,6 @@ void RBKit::CpuStorage::fillCallGraphModel(QStandardItemModel *callGraphModel) void RBKit::CpuStorage::fillFlatProfileModel(QStandardItemModel *flatGraphModel) { - qDebug() << "^^^^^^^^creating flat graph model^^^^^^^^^^^"; QStandardItem *fgRootNode = flatGraphModel->invisibleRootItem(); traverseFlatProfile(*fgRootNode); } diff --git a/rbkit-lib/model/cpustorage.h b/rbkit-lib/model/cpustorage.h index c55204d..3c88485 100644 --- a/rbkit-lib/model/cpustorage.h +++ b/rbkit-lib/model/cpustorage.h @@ -28,7 +28,6 @@ namespace RBKit void updateNewNodeLocation(QString methodName, RBKit::CpuNodePtr); bool exists(QVariant name); unsigned long long getSampleCount(); - void traverseNodes(); void clearFrameStack(); void updateExistingMethod(QMap); void updateSelfCount(); From b98902d4fc520a7156314cf8830dcf66e46c1caf Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Wed, 5 Aug 2015 16:04:35 +0530 Subject: [PATCH 5/9] removed unwanted cpuview related code --- rbkit-lib/ui/centralwidget.cpp | 20 -------------------- rbkit-lib/ui/centralwidget.h | 2 -- 2 files changed, 22 deletions(-) diff --git a/rbkit-lib/ui/centralwidget.cpp b/rbkit-lib/ui/centralwidget.cpp index 2e94dbf..e945a08 100644 --- a/rbkit-lib/ui/centralwidget.cpp +++ b/rbkit-lib/ui/centralwidget.cpp @@ -167,26 +167,6 @@ void CentralWidget::setupCentralView() chartingTab->addTab(memoryView.data(), "Object Charts"); } -void CentralWidget::newCpuView() -{ - QSharedPointer cpuView(new CpuView(this)); - int index = chartingTab->addTab(cpuView.data(), "Cpu Tree"); - cpuViewHash[index] = cpuView; - - connect(cpuView.data(), - SIGNAL(fillCallGraph(QStandardItemModel*)), - RBKit::CpuStorage::getStorage().data(), - SLOT(fillCallGraphModel(QStandardItemModel*))); - - connect(cpuView.data(), - SIGNAL(fillFlatProfile(QStandardItemModel*)), - RBKit::CpuStorage::getStorage().data(), - SLOT(fillFlatProfileModel(QStandardItemModel*))); - - emit cpuView.data()->fillCallGraph(cpuView->callGraphModel); - emit cpuView.data()->fillFlatProfile(cpuView->flatGraphModel); -} - void CentralWidget::showStatusMessage(const QString &message) const { //mainWindow->appStatusBar->showMessage(message); diff --git a/rbkit-lib/ui/centralwidget.h b/rbkit-lib/ui/centralwidget.h index 25793cc..502c3bb 100644 --- a/rbkit-lib/ui/centralwidget.h +++ b/rbkit-lib/ui/centralwidget.h @@ -29,7 +29,6 @@ class CentralWidget : public QWidget QVBoxLayout* mainLayout; QSharedPointer chartingTab; QSharedPointer memoryView; - QHash> cpuViewHash; QStackedWidget *mainWindow; RBKit::SnapshotState *snapshotState; QTimer *snapshotProgressTimer; @@ -57,7 +56,6 @@ public slots: void receiveOldGenStats(QVariantMap map); void objectDumpAvailable(int snapshotVersion); void updateProgressBar(); - void newCpuView(); private slots: void tabClosed(int index); void onDiffSnapshotsSelected(QList selectedSnapshots); From 86fe99589fb2f9e4a1fb4ab55f518f6729bb20b3 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Wed, 5 Aug 2015 16:17:24 +0530 Subject: [PATCH 6/9] re-enabled some progress bar and status related functions they were disabled while moving to qstackedwidget --- rbkit-lib/ui/appmainwindow.cpp | 2 +- rbkit-lib/ui/centralwidget.cpp | 11 +++++------ rbkit-lib/ui/centralwidget.h | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/rbkit-lib/ui/appmainwindow.cpp b/rbkit-lib/ui/appmainwindow.cpp index a68b8ca..d2167e1 100644 --- a/rbkit-lib/ui/appmainwindow.cpp +++ b/rbkit-lib/ui/appmainwindow.cpp @@ -15,7 +15,7 @@ AppMainwindow::AppMainwindow(QWidget *parent) : QMainWindow(parent) stackedWidget = new StackedWidget(this); setCentralWidget(mainWidget); - centralMemoryWidget = new CentralWidget(stackedWidget); + centralMemoryWidget = new CentralWidget(stackedWidget, this); int index = stackedWidget->addWidget(centralMemoryWidget); actionToolBar = QSharedPointer::create(this, centralMemoryWidget); diff --git a/rbkit-lib/ui/centralwidget.cpp b/rbkit-lib/ui/centralwidget.cpp index e945a08..e77f261 100644 --- a/rbkit-lib/ui/centralwidget.cpp +++ b/rbkit-lib/ui/centralwidget.cpp @@ -89,7 +89,7 @@ void CentralWidget::objectDumpAvailable(int snapshotVersion) QString snapshotName = QString("Heap Dump #%0").arg(snapshotVersion); snapshotState->addNewSnapshot(heapUI, snapshotName); showStatusMessage("Heap snapshot complete"); - //mainWindow->appStatusBar->clearMessage(); + mainWindow->appStatusBar->clearMessage(); setProgressBarValue(100); snapshotProgressTimer->stop(); snapshotState->setSnapshotProgress(false); @@ -110,7 +110,6 @@ void CentralWidget::tabClosed(int index) return; chartingTab->removeTab(index); snapshotState->removeSnapshot(index); - cpuViewHash.remove(index); } void CentralWidget::onDiffSnapshotsSelected(QList selectedSnapshots) @@ -129,7 +128,7 @@ QList CentralWidget::diffableSnapshotVersions() return snapshotState->diffableSnapshotVersions(); } -CentralWidget::CentralWidget(QStackedWidget *window) : QWidget(window) +CentralWidget::CentralWidget(StackedWidget *mainWindow, AppMainwindow *window) : QWidget(mainWindow) , mainWindow(window) { mainLayout = new QVBoxLayout(); @@ -169,17 +168,17 @@ void CentralWidget::setupCentralView() void CentralWidget::showStatusMessage(const QString &message) const { - //mainWindow->appStatusBar->showMessage(message); + mainWindow->appStatusBar->showMessage(message); } void CentralWidget::setProgressBarValue(int value) const { - //mainWindow->progressBar->setValue(value); + mainWindow->progressBar->setValue(value); } void CentralWidget::resetProgressBar() const { - //mainWindow->progressBar->reset(); + mainWindow->progressBar->reset(); } bool CentralWidget::attemptMemorySnapshot() diff --git a/rbkit-lib/ui/centralwidget.h b/rbkit-lib/ui/centralwidget.h index 502c3bb..53f7380 100644 --- a/rbkit-lib/ui/centralwidget.h +++ b/rbkit-lib/ui/centralwidget.h @@ -29,13 +29,13 @@ class CentralWidget : public QWidget QVBoxLayout* mainLayout; QSharedPointer chartingTab; QSharedPointer memoryView; - QStackedWidget *mainWindow; + AppMainwindow *mainWindow; RBKit::SnapshotState *snapshotState; QTimer *snapshotProgressTimer; QList diffableSnapshotVersions(); public: - explicit CentralWidget(QStackedWidget *mainWindow); + explicit CentralWidget(StackedWidget *mainWindow, AppMainwindow *window); ~CentralWidget(); void setupCentralView(); void showStatusMessage(const QString &message) const; From ddd74f20d872632662d6abebdb3bad74dc657705 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Wed, 5 Aug 2015 16:19:11 +0530 Subject: [PATCH 7/9] removed an unwanted debugging message --- rbkit-lib/ui/cpuview.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/rbkit-lib/ui/cpuview.cpp b/rbkit-lib/ui/cpuview.cpp index 1011acf..3e469ec 100644 --- a/rbkit-lib/ui/cpuview.cpp +++ b/rbkit-lib/ui/cpuview.cpp @@ -26,7 +26,6 @@ CpuView::CpuView(QWidget *parent) : CpuView::~CpuView() { - qDebug() << "**************deleting Cpu View*******************"; delete ui; } From e961905d6b6057aaac1ace66b2c8f4ad72c31910 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Thu, 6 Aug 2015 16:57:03 +0530 Subject: [PATCH 8/9] removed the unsused rbkitmainwindow.ui --- rbkit-lib/CMakeLists.txt | 1 - rbkit-lib/ui/rbkitmainwindow.ui | 171 -------------------------------- 2 files changed, 172 deletions(-) delete mode 100644 rbkit-lib/ui/rbkitmainwindow.ui diff --git a/rbkit-lib/CMakeLists.txt b/rbkit-lib/CMakeLists.txt index 85dfc73..bca16eb 100644 --- a/rbkit-lib/CMakeLists.txt +++ b/rbkit-lib/CMakeLists.txt @@ -18,7 +18,6 @@ include_directories( QT5_WRAP_UI(RBKIT_UI_HEADERS - ui/rbkitmainwindow.ui ui/askhost.ui ui/heapdumpform.ui ui/memoryview.ui diff --git a/rbkit-lib/ui/rbkitmainwindow.ui b/rbkit-lib/ui/rbkitmainwindow.ui deleted file mode 100644 index c50d7f7..0000000 --- a/rbkit-lib/ui/rbkitmainwindow.ui +++ /dev/null @@ -1,171 +0,0 @@ - - - RbkitMainWindow - - - - 0 - 0 - 1100 - 840 - - - - - 850 - 840 - - - - Rbkit - A Ruby Profiler - - - - - - - QTabWidget::North - - - -1 - - - true - - - - - - - - - 0 - 0 - 1100 - 22 - - - - - &File - - - - - - - &Help - - - - - - &Memory Profiling - - - - - - - - - - - - - toolBar - - - true - - - false - - - - 16 - 16 - - - - Qt::ToolButtonTextBesideIcon - - - false - - - TopToolBarArea - - - false - - - - - - - - - - - :/icons/connect-48.png:/icons/connect-48.png - - - &Connect - - - - - &Quit - - - Quit Rbkit - - - Ctrl+Q - - - - - &About Rbkit - - - - - - :/icons/startgc-48.png:/icons/startgc-48.png - - - &Start GC - - - - - - :/icons/snapshot-48.png:/icons/snapshot-48.png - - - Heap Snapshot - - - Record heapsnapshot - - - - - - :/icons/Compare-48.png:/icons/Compare-48.png - - - Compare Snapshots - - - Compare Heapsnpshot - - - - - - - - From 0a8ea57ea092dc6e1eb3660ac5cfa4b704e7f851 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Thu, 6 Aug 2015 17:38:44 +0530 Subject: [PATCH 9/9] keeping a reference of appmainwindow instead of pointer --- rbkit-lib/ui/actiontoolbar.cpp | 4 ++-- rbkit-lib/ui/actiontoolbar.h | 4 ++-- rbkit-lib/ui/appmainwindow.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rbkit-lib/ui/actiontoolbar.cpp b/rbkit-lib/ui/actiontoolbar.cpp index f608dea..e4a956a 100644 --- a/rbkit-lib/ui/actiontoolbar.cpp +++ b/rbkit-lib/ui/actiontoolbar.cpp @@ -26,7 +26,7 @@ static void toggleConnectButtonState(ConnectionStates state, QToolButton *btn) { } } -ActionToolbar::ActionToolbar(AppMainwindow *window, CentralWidget *widget) +ActionToolbar::ActionToolbar(AppMainwindow &window, CentralWidget *widget) : centralWidget(widget), window(window) { Q_INIT_RESOURCE(tool_icons); @@ -157,7 +157,7 @@ void ActionToolbar::setupToolBar() QIcon(":/icons/Compare-32.png"), "cpu_profiling"); connect(stopCPUButton, &QToolButton::clicked, this, &ActionToolbar::performStopCPUAction); - connect(this, SIGNAL(stopCPUProfiling()), window, SLOT(newCpuView())); + connect(this, SIGNAL(stopCPUProfiling()), &window, SLOT(newCpuView())); toolBar->loadStyleSheet(":/icons/style.css"); } diff --git a/rbkit-lib/ui/actiontoolbar.h b/rbkit-lib/ui/actiontoolbar.h index a1dc652..bed4669 100644 --- a/rbkit-lib/ui/actiontoolbar.h +++ b/rbkit-lib/ui/actiontoolbar.h @@ -39,9 +39,9 @@ class ActionToolbar : public QObject Subscriber *subscriber; ConnectionStates connectionState; QThread subscriberThread; - AppMainwindow *window; + AppMainwindow &window; public: - explicit ActionToolbar(AppMainwindow *window , CentralWidget *widget); + explicit ActionToolbar(AppMainwindow &window , CentralWidget *widget); void enableProfileActions(); void disableProfileActions(); void setupToolBar(); diff --git a/rbkit-lib/ui/appmainwindow.cpp b/rbkit-lib/ui/appmainwindow.cpp index d2167e1..8d7882b 100644 --- a/rbkit-lib/ui/appmainwindow.cpp +++ b/rbkit-lib/ui/appmainwindow.cpp @@ -18,7 +18,7 @@ AppMainwindow::AppMainwindow(QWidget *parent) : QMainWindow(parent) centralMemoryWidget = new CentralWidget(stackedWidget, this); int index = stackedWidget->addWidget(centralMemoryWidget); - actionToolBar = QSharedPointer::create(this, centralMemoryWidget); + actionToolBar = QSharedPointer::create(*this, centralMemoryWidget); cpuTab = new QTabWidget(stackedWidget); cpuTab->setTabsClosable(true);