From 93984ce1c07dfe5756e3fadf3fae799c20e3ee4a Mon Sep 17 00:00:00 2001 From: maelstrom Date: Thu, 14 Aug 2025 17:21:55 +0200 Subject: [PATCH] fix(editor): hidden internal services --- core/src/objects/service/jointsservice.h | 2 +- .../src/objects/service/script/scriptcontext.h | 2 +- .../service/script/serverscriptservice.h | 2 +- core/src/objects/service/selection.h | 2 +- editor/panes/explorermodel.cpp | 18 ++++++++++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/src/objects/service/jointsservice.h b/core/src/objects/service/jointsservice.h index 43c59ab..0bcc3c2 100644 --- a/core/src/objects/service/jointsservice.h +++ b/core/src/objects/service/jointsservice.h @@ -3,7 +3,7 @@ #include "objects/annotation.h" #include "objects/base/service.h" -class DEF_INST_SERVICE JointsService : public Service { +class DEF_INST_SERVICE_(hidden) JointsService : public Service { AUTOGEN_PREAMBLE private: std::optional> jointWorkspace(); diff --git a/core/src/objects/service/script/scriptcontext.h b/core/src/objects/service/script/scriptcontext.h index 3c2df2f..569339b 100644 --- a/core/src/objects/service/script/scriptcontext.h +++ b/core/src/objects/service/script/scriptcontext.h @@ -15,7 +15,7 @@ struct SleepingThread { class Script; -class DEF_INST_SERVICE ScriptContext : public Service { +class DEF_INST_SERVICE_(hidden) ScriptContext : public Service { AUTOGEN_PREAMBLE std::vector sleepingThreads; diff --git a/core/src/objects/service/script/serverscriptservice.h b/core/src/objects/service/script/serverscriptservice.h index c488786..1224704 100644 --- a/core/src/objects/service/script/serverscriptservice.h +++ b/core/src/objects/service/script/serverscriptservice.h @@ -5,7 +5,7 @@ // Container class for server scripts // Also handles/manages running server scripts on run -class DEF_INST_SERVICE_(explorer_icon="server-scripts") ServerScriptService : public Service { +class DEF_INST_SERVICE_(explorer_icon="server-scripts", hidden) ServerScriptService : public Service { AUTOGEN_PREAMBLE protected: void InitService() override; diff --git a/core/src/objects/service/selection.h b/core/src/objects/service/selection.h index 43c6e2b..a32a747 100644 --- a/core/src/objects/service/selection.h +++ b/core/src/objects/service/selection.h @@ -6,7 +6,7 @@ #include #include -class DEF_INST_SERVICE Selection : public Service { +class DEF_INST_SERVICE_(hidden) Selection : public Service { AUTOGEN_PREAMBLE private: std::vector> selection; diff --git a/editor/panes/explorermodel.cpp b/editor/panes/explorermodel.cpp index 5137eb2..12d09a5 100644 --- a/editor/panes/explorermodel.cpp +++ b/editor/panes/explorermodel.cpp @@ -8,6 +8,10 @@ #include #include +#ifdef _NDEBUG +#define NDEBUG +#endif + #define M_mainWindow dynamic_cast(dynamic_cast(dynamic_cast(this)->parent())->window()) // https://doc.qt.io/qt-6/qtwidgets-itemviews-simpletreemodel-example.html#testing-the-model @@ -49,8 +53,14 @@ QModelIndex ExplorerModel::index(int row, int column, const QModelIndex &parent) ? static_cast(parent.internalPointer()) : rootItem.get(); +#ifdef NDEBUG if (parentItem->GetChildren().size() >= (size_t)row && !(parentItem->GetChildren()[row]->GetClass()->flags & INSTANCE_HIDDEN)) return createIndex(row, column, parentItem->GetChildren()[row].get()); +#else + // Don't hide in debug builds + if (parentItem->GetChildren().size() >= (size_t)row) + return createIndex(row, column, parentItem->GetChildren()[row].get()); +#endif return {}; } @@ -97,7 +107,15 @@ int ExplorerModel::rowCount(const QModelIndex &parent) const { ? static_cast(parent.internalPointer()) : rootItem.get(); +#ifdef NDEBUG + // Trim trailing hidden items as they make the branches look weird + int count = parentItem->GetChildren().size(); + while (count > 0 && parentItem->GetChildren()[count-1]->GetClass()->flags & INSTANCE_HIDDEN) count--; + return count; +#else + // Don't hide in debug builds return parentItem->GetChildren().size(); +#endif } int ExplorerModel::columnCount(const QModelIndex &parent) const {