From 1dde9e7e753467d2e1a5f73434e4b92ca706a992 Mon Sep 17 00:00:00 2001 From: harry Date: Tue, 16 Jan 2024 22:04:00 -0500 Subject: [PATCH] Minor fixes for JS global variable viewer. --- src/drivers/Qt/QtScriptManager.cpp | 6 ++++-- src/drivers/Qt/QtScriptManager.h | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/drivers/Qt/QtScriptManager.cpp b/src/drivers/Qt/QtScriptManager.cpp index cfe9645b5..15917cb15 100644 --- a/src/drivers/Qt/QtScriptManager.cpp +++ b/src/drivers/Qt/QtScriptManager.cpp @@ -742,7 +742,7 @@ void QScriptDialog_t::closeWindow(void) deleteLater(); } //---------------------------------------------------- -void QScriptDialog_t::loadPropertyTree(QJSValue& object, QTreeWidgetItem* parentItem) +void QScriptDialog_t::loadPropertyTree(QJSValue& object, JsPropertyItem* parentItem) { QJSValueIterator it(object); @@ -755,7 +755,7 @@ void QScriptDialog_t::loadPropertyTree(QJSValue& object, QTreeWidgetItem* parent if (!isPrototype) { - QTreeWidgetItem* item = new QTreeWidgetItem(); + JsPropertyItem* item = new JsPropertyItem(); QString value; const char *type = "unknown"; @@ -833,6 +833,7 @@ void QScriptDialog_t::loadPropertyTree(QJSValue& object, QTreeWidgetItem* parent item->setText(0, it.name()); item->setText(1, type); item->setText(2, value); + item->jsValue = child; if (parentItem == nullptr) { @@ -1055,6 +1056,7 @@ void QScriptDialog_t::startScript(void) QJSValue globals = scriptInstance->getEngine()->globalObject(); + propTree->clear(); loadPropertyTree(globals); FCEU_WRAPPER_UNLOCK(); diff --git a/src/drivers/Qt/QtScriptManager.h b/src/drivers/Qt/QtScriptManager.h index 60c53369e..4914e7482 100644 --- a/src/drivers/Qt/QtScriptManager.h +++ b/src/drivers/Qt/QtScriptManager.h @@ -139,6 +139,22 @@ public slots: void frameFinishedUpdate(); }; +class JsPropertyItem : public QTreeWidgetItem +{ +public: + JsPropertyItem() + : QTreeWidgetItem() + { + } + + virtual ~JsPropertyItem() override + { + } + + QJSValue jsValue; + QMap childMap; +}; + class QScriptDialog_t : public QDialog { Q_OBJECT @@ -153,7 +169,7 @@ class QScriptDialog_t : public QDialog protected: void closeEvent(QCloseEvent *bar); void openJSKillMessageBox(void); - void loadPropertyTree(QJSValue& val, QTreeWidgetItem* parentItem = nullptr); + void loadPropertyTree(QJSValue& val, JsPropertyItem* parentItem = nullptr); QTimer *periodicTimer; QLineEdit *scriptPath;