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 77872d8b3..c27d3ca6c 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -75,12 +75,8 @@ namespace GUIEditor void CPropBrowserCtrl::clear() { + disablePropertyWatchers(); browser->clear(); - disconnect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ), - this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) ); - - disconnect( enumMgr, SIGNAL( valueChanged( QtProperty*, int ) ), - this, SLOT( onEnumPropertyChanged( QtProperty*, int ) ) ); } void CPropBrowserCtrl::onSelectionChanged( std::string &id ) @@ -88,21 +84,13 @@ namespace GUIEditor if( browser == NULL ) return; - disconnect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ), - this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) ); - disconnect( enumMgr, SIGNAL( valueChanged( QtProperty*, int ) ), - this, SLOT( onEnumPropertyChanged( QtProperty*, int ) ) ); - + disablePropertyWatchers(); browser->clear(); CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( id ); if( e == NULL ) { - connect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ), - this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) ); - connect( enumMgr, SIGNAL( valueChanged( QtProperty*, int ) ), - this, SLOT( onEnumPropertyChanged( QtProperty*, int ) ) ); - + enablePropertyWatchers(); return; } @@ -111,10 +99,7 @@ namespace GUIEditor std::string n = e->getClassName(); setupProperties( n, e ); - connect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ), - this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) ); - connect( enumMgr, SIGNAL( valueChanged( QtProperty*, int ) ), - this, SLOT( onEnumPropertyChanged( QtProperty*, int ) ) ); + enablePropertyWatchers(); } void CPropBrowserCtrl::onPropertyChanged( QtProperty *prop, const QVariant &v ) @@ -176,6 +161,22 @@ namespace GUIEditor } } + void CPropBrowserCtrl::enablePropertyWatchers() + { + connect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ), + this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) ); + connect( enumMgr, SIGNAL( valueChanged( QtProperty*, int ) ), + this, SLOT( onEnumPropertyChanged( QtProperty*, int ) ) ); + } + + void CPropBrowserCtrl::disablePropertyWatchers() + { + disconnect( propertyMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ), + this, SLOT( onPropertyChanged( QtProperty*, const QVariant& ) ) ); + disconnect( enumMgr, SIGNAL( valueChanged( QtProperty*, int ) ), + this, SLOT( onEnumPropertyChanged( QtProperty*, int ) ) ); + } + void CPropBrowserCtrl::setupProperties( const std::string &type, const CInterfaceElement *element ) { std::map< std::string, SWidgetInfo >::iterator itr = widgetInfo.find( type ); 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 648463bc6..f8d839bd6 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h @@ -59,6 +59,9 @@ namespace GUIEditor void onEnumPropertyChanged( QtProperty *prop, int value ); private: + void enablePropertyWatchers(); + void disablePropertyWatchers(); + void setupProperties( const std::string &type, const NLGUI::CInterfaceElement *element ); void setupProperty( const SPropEntry &prop, const NLGUI::CInterfaceElement *element );