From ede98df6acf2e83ff7f36d4a369e4289881087c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Tue, 18 Jun 2019 19:57:07 +0200 Subject: [PATCH] Fix initial objectName for Memory Widgets --- src/core/MainWindow.cpp | 9 +++------ src/core/MainWindow.h | 4 ++-- src/widgets/DisassemblyWidget.cpp | 3 ++- src/widgets/GraphWidget.cpp | 3 ++- src/widgets/HexdumpWidget.cpp | 3 ++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 62a35b66..9fa587e7 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -312,7 +312,7 @@ void MainWindow::initDocks() vTablesDock = new VTablesWidget(this, ui->actionVTables); QSettings s; - QStringList docks = s.value("docks").toStringList(); + QStringList docks = s.value("docks", QStringList { GraphWidget::getWidgetType() }).toStringList(); // Restore all extra widgets QString className; @@ -373,21 +373,18 @@ void MainWindow::updateTasksIndicator() void MainWindow::addExtraGraph() { auto *extraDock = new GraphWidget(this, ui->actionGraph); - extraDock->setObjectName(getUniqueObjectName(extraDock->getWidgetType())); addExtraWidget(extraDock); } void MainWindow::addExtraHexdump() { auto *extraDock = new HexdumpWidget(this, ui->actionHexdump); - extraDock->setObjectName(getUniqueObjectName(extraDock->getWidgetType())); addExtraWidget(extraDock); } void MainWindow::addExtraDisassembly() { auto *extraDock = new DisassemblyWidget(this, ui->actionDisassembly); - extraDock->setObjectName(getUniqueObjectName(extraDock->getWidgetType())); addExtraWidget(extraDock); } @@ -857,14 +854,14 @@ void MainWindow::updateDockActionsChecked() } } -QString MainWindow::getUniqueObjectName(const QString& widgetType) const +QString MainWindow::getUniqueObjectName(const QString &widgetType) const { QStringList docks; docks.reserve(dockWidgets.size()); QString name; for (const auto &it : dockWidgets) { name = it->objectName(); - if (name.split(';').at(0) == widgetType && name != "Graph Overview") { + if (name.split(';').at(0) == widgetType) { docks.push_back(name); } } diff --git a/src/core/MainWindow.h b/src/core/MainWindow.h index b77716b3..42ba25c4 100644 --- a/src/core/MainWindow.h +++ b/src/core/MainWindow.h @@ -110,6 +110,8 @@ public: } void messageBoxWarning(QString title, QString message); + QString getUniqueObjectName(const QString &widgetType) const; + public slots: void finalizeOpen(); @@ -276,8 +278,6 @@ private: * pointer to class constructor and action that passed to this constructor. */ QMap, QAction*>> classNameToConstructorAndActionMap; - - QString getUniqueObjectName(const QString &widgetType) const; }; #endif // MAINWINDOW_H diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index d4a2ee17..e53ebe76 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -3,6 +3,7 @@ #include "common/Configuration.h" #include "common/Helpers.h" #include "common/TempConfig.h" +#include "core/MainWindow.h" #include #include @@ -39,7 +40,7 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action) , mDisasScrollArea(new DisassemblyScrollArea(this)) , mDisasTextEdit(new DisassemblyTextEdit(this)) { - setObjectName(getWidgetType()); + setObjectName(main->getUniqueObjectName(getWidgetType())); topOffset = bottomOffset = RVA_INVALID; cursorLineOffset = 0; diff --git a/src/widgets/GraphWidget.cpp b/src/widgets/GraphWidget.cpp index c69f4c49..ea151610 100644 --- a/src/widgets/GraphWidget.cpp +++ b/src/widgets/GraphWidget.cpp @@ -6,7 +6,8 @@ GraphWidget::GraphWidget(MainWindow *main, QAction *action) : MemoryDockWidget(CutterCore::MemoryWidgetType::Graph, main, action) { - setObjectName(getWidgetType()); + setObjectName(main->getUniqueObjectName(getWidgetType())); + setAllowedAreas(Qt::AllDockWidgetAreas); graphView = new DisassemblerGraphView(this, seekable); setWidget(graphView); diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index 74b27256..35c3919d 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -4,6 +4,7 @@ #include "common/Helpers.h" #include "common/Configuration.h" #include "common/TempConfig.h" +#include "core/MainWindow.h" #include #include @@ -21,7 +22,7 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) : { ui->setupUi(this); - setObjectName(getWidgetType()); + setObjectName(main->getUniqueObjectName(getWidgetType())); ui->copyMD5->setIcon(QIcon(":/img/icons/copy.svg")); ui->copySHA1->setIcon(QIcon(":/img/icons/copy.svg"));