From b88e53c685c3b4388e6ee4eb885d7e84d4c1d398 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 27 Jun 2014 00:47:29 +0200 Subject: [PATCH] Got rid of a memleak. --HG-- branch : gsoc2014-dfighter --- .../gui_editor/property_browser_ctrl.cpp | 22 ++++++++++++++----- .../gui_editor/property_browser_ctrl.h | 5 +++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp index 7effe6765..4a839cbee 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -198,6 +198,9 @@ namespace GUIEditor browser = NULL; propertyMgr = new QtVariantPropertyManager; enumMgr = new QtEnumPropertyManager; + + variantFactory = new QtVariantEditorFactory; + enumFactory = new QtEnumEditorFactory; } CPropBrowserCtrl::~CPropBrowserCtrl() @@ -207,6 +210,11 @@ namespace GUIEditor delete propertyMgr; propertyMgr = NULL; + delete variantFactory; + variantFactory = NULL; + delete enumFactory; + enumFactory = NULL; + browser = NULL; } @@ -257,6 +265,14 @@ namespace GUIEditor std::string n = e->getClassName(); setupProperties( n, e ); + + + // Need to set these up every time, otherwise the editors won't work + // probably the clear() method clears them too... + browser->setFactoryForManager( propertyMgr, variantFactory ); + browser->setFactoryForManager( enumMgr, enumFactory ); + + enablePropertyWatchers(); } @@ -381,12 +397,6 @@ namespace GUIEditor nameToType[ prop.propName ] = prop.propType; setupProperty( prop, element ); } - - QtVariantEditorFactory *factory = new QtVariantEditorFactory; - browser->setFactoryForManager( propertyMgr, factory ); - - QtEnumEditorFactory *efactory = new QtEnumEditorFactory; - browser->setFactoryForManager( enumMgr, efactory ); } void CPropBrowserCtrl::setupProperty( const SPropEntry &prop, const CInterfaceElement *element ) diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h index f53648f79..efb785d9b 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h @@ -26,6 +26,8 @@ class QtTreePropertyBrowser; class QtVariantPropertyManager; class QtEnumPropertyManager; +class QtVariantEditorFactory; +class QtEnumEditorFactory; class QtProperty; class QVariant; @@ -69,6 +71,9 @@ namespace GUIEditor QtVariantPropertyManager *propertyMgr; QtEnumPropertyManager *enumMgr; + QtVariantEditorFactory *variantFactory; + QtEnumEditorFactory *enumFactory; + std::string currentElement; std::map< std::string, SWidgetInfo > widgetInfo; std::map< std::string, std::string > nameToType;