mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 17:29:10 +00:00
FIXED: Deleting the CViewText of CCtrlTextButton should no longer lead to crashes.
This commit is contained in:
parent
31c6fc459f
commit
69954d6e8b
6 changed files with 73 additions and 37 deletions
|
@ -125,6 +125,7 @@ namespace NLGUI
|
|||
REFLECT_EXPORT_END
|
||||
|
||||
void onRemoved();
|
||||
void onWidgetDeleted( CInterfaceElement *e );
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -503,6 +503,10 @@ namespace NLGUI
|
|||
/// Unregisters a deletion watcher
|
||||
static void unregisterDeletionWatcher( IDeletionWatcher *watcher );
|
||||
|
||||
/// Called when the widget is deleted,
|
||||
/// so other widgets in the group can check if it belongs to them
|
||||
virtual void onWidgetDeleted( CInterfaceElement *e ){}
|
||||
|
||||
protected:
|
||||
|
||||
bool editorSelected;
|
||||
|
|
|
@ -322,6 +322,8 @@ namespace NLGUI
|
|||
// Return the current Depth, with no ZBias applied.
|
||||
float getDepthForZSort() const { return _DepthForZSort; }
|
||||
|
||||
void onWidgetDeleted( CInterfaceElement *e );
|
||||
|
||||
protected:
|
||||
|
||||
void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH);
|
||||
|
|
|
@ -65,10 +65,8 @@ namespace NLGUI
|
|||
if( _ViewText != NULL )
|
||||
{
|
||||
if( _Parent != NULL )
|
||||
_Parent->delView( _ViewText );
|
||||
else
|
||||
_Parent->delView( _ViewText, true );
|
||||
delete _ViewText;
|
||||
|
||||
_ViewText = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +122,10 @@ namespace NLGUI
|
|||
else
|
||||
if( name == "hardtext" )
|
||||
{
|
||||
if( _ViewText != NULL )
|
||||
return _ViewText->getText().toString();
|
||||
else
|
||||
return std::string( "" );
|
||||
}
|
||||
else
|
||||
if( name == "text_y" )
|
||||
|
@ -139,7 +140,10 @@ namespace NLGUI
|
|||
else
|
||||
if( name == "text_underlined" )
|
||||
{
|
||||
if( _ViewText != NULL )
|
||||
return toString( _ViewText->getUnderlined() );
|
||||
else
|
||||
return std::string( "" );
|
||||
}
|
||||
else
|
||||
if( name == "text_posref" )
|
||||
|
@ -280,6 +284,7 @@ namespace NLGUI
|
|||
else
|
||||
if( name == "hardtext" )
|
||||
{
|
||||
if( _ViewText != NULL )
|
||||
_ViewText->setText( value );
|
||||
return;
|
||||
}
|
||||
|
@ -303,8 +308,10 @@ namespace NLGUI
|
|||
if( name == "text_underlined" )
|
||||
{
|
||||
bool b;
|
||||
if( _ViewText != NULL )
|
||||
if( fromString( value, b ) )
|
||||
_ViewText->setUnderlined( b );
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -813,6 +820,8 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
// Setup ViewText color
|
||||
if( _ViewText != NULL )
|
||||
{
|
||||
if ( pTxId==_TextureIdNormal || editorMode )
|
||||
{
|
||||
if(_TextHeaderColor) viewTextColor.A= _TextColorNormal.A;
|
||||
|
@ -840,6 +849,7 @@ namespace NLGUI
|
|||
if(getFrozen() && getFrozenHalfTone())
|
||||
_ViewText->setAlpha(_ViewText->getAlpha()>>2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -978,5 +988,11 @@ namespace NLGUI
|
|||
_Parent->delView( _ViewText, true );
|
||||
}
|
||||
}
|
||||
|
||||
void CCtrlTextButton::onWidgetDeleted( CInterfaceElement *e )
|
||||
{
|
||||
if( e == _ViewText )
|
||||
_ViewText = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,11 @@ namespace NLGUI
|
|||
}
|
||||
|
||||
if( editorMode )
|
||||
{
|
||||
notifyDeletionWatchers();
|
||||
if( _Parent != NULL )
|
||||
_Parent->onWidgetDeleted( this );
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1088,7 +1088,6 @@ namespace NLGUI
|
|||
_Views.erase(_Views.begin()+i);
|
||||
delEltOrder (child);
|
||||
child->onRemoved();
|
||||
child->setParent( NULL );
|
||||
if (!dontDelete) delete v;
|
||||
return true;
|
||||
}
|
||||
|
@ -1107,7 +1106,6 @@ namespace NLGUI
|
|||
_Controls.erase(_Controls.begin()+i);
|
||||
delEltOrder (child);
|
||||
child->onRemoved();
|
||||
child->setParent( NULL );
|
||||
if (!dontDelete) delete c;
|
||||
return true;
|
||||
}
|
||||
|
@ -1126,7 +1124,6 @@ namespace NLGUI
|
|||
_ChildrenGroups.erase(_ChildrenGroups.begin()+i);
|
||||
delEltOrder (child);
|
||||
child->onRemoved();
|
||||
child->setParent( NULL );
|
||||
if (!dontDelete) delete g;
|
||||
return true;
|
||||
}
|
||||
|
@ -2477,4 +2474,16 @@ namespace NLGUI
|
|||
return "IMPLEMENT ME!";
|
||||
}
|
||||
|
||||
void CInterfaceGroup::onWidgetDeleted( CInterfaceElement *e )
|
||||
{
|
||||
for( std::vector< CViewBase* >::iterator itr = _Views.begin(); itr != _Views.end(); ++itr )
|
||||
(*itr)->onWidgetDeleted( e );
|
||||
|
||||
for( std::vector< CCtrlBase* >::iterator itr = _Controls.begin(); itr != _Controls.end(); ++itr )
|
||||
(*itr)->onWidgetDeleted( e );
|
||||
|
||||
for( std::vector< CInterfaceGroup* >::iterator itr = _ChildrenGroups.begin(); itr != _ChildrenGroups.end(); ++itr )
|
||||
(*itr)->onWidgetDeleted( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue