Got rid of a memleak.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-06-27 00:47:29 +02:00
parent 0c4e0e63cc
commit b88e53c685
2 changed files with 21 additions and 6 deletions

View file

@ -198,6 +198,9 @@ namespace GUIEditor
browser = NULL; browser = NULL;
propertyMgr = new QtVariantPropertyManager; propertyMgr = new QtVariantPropertyManager;
enumMgr = new QtEnumPropertyManager; enumMgr = new QtEnumPropertyManager;
variantFactory = new QtVariantEditorFactory;
enumFactory = new QtEnumEditorFactory;
} }
CPropBrowserCtrl::~CPropBrowserCtrl() CPropBrowserCtrl::~CPropBrowserCtrl()
@ -207,6 +210,11 @@ namespace GUIEditor
delete propertyMgr; delete propertyMgr;
propertyMgr = NULL; propertyMgr = NULL;
delete variantFactory;
variantFactory = NULL;
delete enumFactory;
enumFactory = NULL;
browser = NULL; browser = NULL;
} }
@ -257,6 +265,14 @@ namespace GUIEditor
std::string n = e->getClassName(); std::string n = e->getClassName();
setupProperties( n, e ); 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(); enablePropertyWatchers();
} }
@ -381,12 +397,6 @@ namespace GUIEditor
nameToType[ prop.propName ] = prop.propType; nameToType[ prop.propName ] = prop.propType;
setupProperty( prop, element ); 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 ) void CPropBrowserCtrl::setupProperty( const SPropEntry &prop, const CInterfaceElement *element )

View file

@ -26,6 +26,8 @@
class QtTreePropertyBrowser; class QtTreePropertyBrowser;
class QtVariantPropertyManager; class QtVariantPropertyManager;
class QtEnumPropertyManager; class QtEnumPropertyManager;
class QtVariantEditorFactory;
class QtEnumEditorFactory;
class QtProperty; class QtProperty;
class QVariant; class QVariant;
@ -69,6 +71,9 @@ namespace GUIEditor
QtVariantPropertyManager *propertyMgr; QtVariantPropertyManager *propertyMgr;
QtEnumPropertyManager *enumMgr; QtEnumPropertyManager *enumMgr;
QtVariantEditorFactory *variantFactory;
QtEnumEditorFactory *enumFactory;
std::string currentElement; std::string currentElement;
std::map< std::string, SWidgetInfo > widgetInfo; std::map< std::string, SWidgetInfo > widgetInfo;
std::map< std::string, std::string > nameToType; std::map< std::string, std::string > nameToType;