From 68bfbd0707f96be2bd5a6bf41574eff089d29dd7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 23 Apr 2024 10:28:50 +0200 Subject: [PATCH] Gui: simplify singleton of PropertyItemFactory --- src/Gui/propertyeditor/PropertyItem.cpp | 14 ++------------ src/Gui/propertyeditor/PropertyItem.h | 3 --- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 25c0733dd60a..7450b6b01060 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -82,20 +82,10 @@ float fromPercent(int value) } -Gui::PropertyEditor::PropertyItemFactory* Gui::PropertyEditor::PropertyItemFactory::_singleton = nullptr; - PropertyItemFactory& PropertyItemFactory::instance() { - if (!_singleton) { - _singleton = new PropertyItemFactory; - } - return *_singleton; -} - -void PropertyItemFactory::destruct () -{ - delete _singleton; - _singleton = nullptr; + static PropertyItemFactory inst; + return inst; } PropertyItem* PropertyItemFactory::createPropertyItem (const char* sName) const diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index 169f21823b3d..806383e09a5a 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -90,13 +90,10 @@ class GuiExport PropertyItemFactory : public Base::Factory { public: static PropertyItemFactory& instance(); - static void destruct (); PropertyItem* createPropertyItem (const char* sName) const; private: - static PropertyItemFactory* _singleton; - PropertyItemFactory() = default; ~PropertyItemFactory() override = default; };