From 4717f03b3a4c10298609663284b91907e23dce3d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 10 May 2013 02:10:18 +0200 Subject: [PATCH] The editor probably shouldn't crash when adding textbutton widget. --- code/nel/src/gui/ctrl_text_button.cpp | 8 ++++++++ code/nel/src/gui/widget_manager.cpp | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index a977902b7..8dbe9b912 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -886,6 +886,14 @@ namespace NLGUI { _Setuped= true; + if( _ViewText == NULL ) + { + CViewBase *v = CWidgetManager::getInstance()->getParser()->createClass( "text" ); + nlassert( v != NULL ); + _ViewText = dynamic_cast< CViewText* >( v ); + _ViewText->setText( ucstring( "text" ) ); + } + // setup the viewText and add to parent _ViewText->setParent (getParent()); _ViewText->setParentPos (this); diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index bad93687b..6e7431b70 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -3289,6 +3289,7 @@ namespace NLGUI return NULL; v->setId( std::string( g->getId() + ":" + widgetName ) ); + v->setParent( g ); if( v->isGroup() ) g->addGroup( dynamic_cast< CInterfaceGroup* >( v ) ); @@ -3298,8 +3299,6 @@ namespace NLGUI else g->addView( v ); - v->setParent( g ); - notifyAdditionWatchers( v->getId() ); return v;