[yast-commit] r41958 - in /branches/tmp/sh/mod-ui/core/libyui/src: YBarGraph.cc YWidget.cc YWidget.h
Author: sh-sh-sh Date: Sun Nov 11 02:24:24 2007 New Revision: 41958 URL: http://svn.opensuse.org/viewcvs/yast?rev=41958&view=rev Log: enforce widget creation on heap Modified: branches/tmp/sh/mod-ui/core/libyui/src/YBarGraph.cc branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h Modified: branches/tmp/sh/mod-ui/core/libyui/src/YBarGraph.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YBarGraph.cc?rev=41958&r1=41957&r2=41958&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YBarGraph.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YBarGraph.cc Sun Nov 11 02:24:24 2007 @@ -56,7 +56,7 @@ YBarGraph::YBarGraph( YWidget * parent ) - :YWidget( parent ) + : YWidget( parent ) , priv( new YBarGraphPrivate() ) { YUI_CHECK_NEW( priv ); Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc?rev=41958&r1=41957&r2=41958&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc Sun Nov 11 02:24:24 2007 @@ -17,6 +17,8 @@ /-*/ +#include <signal.h> + #include <ycp/YCPBoolean.h> #include <ycp/YCPInteger.h> #include <ycp/YCPSymbol.h> @@ -94,6 +96,9 @@ + +bool YWidget::_usedOperatorNew = false; + // FIXME: Obsolete // FIXME: Obsolete // FIXME: Obsolete @@ -115,11 +120,27 @@ YUI_CHECK_NEW( priv ); YUI_CHECK_NEW( priv->childrenManager ); + if ( ! _usedOperatorNew ) + { + y2error( "FATAL: Widget at %p not created with operator new !", this ); + y2error( "Check core dump for a backtrace." ); + abort(); + } + + _usedOperatorNew = false; + if ( parent ) parent->addChild( this ); } +void * YWidget::operator new( size_t size ) +{ + _usedOperatorNew = true; + return ::operator new( size ); +} + + YWidget::~YWidget() { YUI_CHECK_WIDGET( this ); Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h?rev=41958&r1=41957&r2=41958&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h Sun Nov 11 02:24:24 2007 @@ -66,7 +66,7 @@ public: /** - * Destructor + * Destructor. **/ virtual ~YWidget(); @@ -575,6 +575,15 @@ **/ virtual void saveUserInput( YMacroRecorder *macroRecorder ); + /** + * Overloaded operator new to ensure widgets are always created on the + * heap, never on the stack. + * + * Simpler implementations of this have a tendency to be fooled by poorly + * implemented derived classes. + **/ + void * operator new( size_t size ); + // NCurses optimizations @@ -653,7 +662,7 @@ ImplPtr<YWidgetPrivate> priv; static YPropertySet _propertySet; - + static bool _usedOperatorNew; #include "YWidget_OptimizeChanges.h" -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
sh-sh-sh@svn.opensuse.org