This is a discussion on re: NULL_vptr - KDE ; Greetings Craig, i think there is something wrong about the code: .... s_self =3D new RealFactory(); .... in C++, operator() is invoked and the resulting functor is then passed to = operator new for initialization. Is that desirable? --- wrote: ...
Greetings Craig,
i think there is something wrong about the code:
....
s_self =3D new RealFactory();
....
in C++, operator() is invoked and the resulting functor is then passed to =
operator new for initialization. Is that desirable?
---wrote:
>I'm working on a KPart and I've got essentially the following:
>
>class PublicFactory : public KParts::Factory {
> public :
> KParts::Part *createPartObject( QWidget *parentWidget, const char =
>*widgetName, QObject *parent, const char *name, const char *classname, =
>const =
>QStringList &args ) {
> return RealFactory::self()->createPartObject( parentWidget, =
>widgetName, =
>parent, name, classname, args );
> }
>};
>
>/* both are static members of RealFactory */
>RealFactory *RealFactory::s_self =3D 0;
>RealFactory *RealFactory::self()
>{
> if ( !s_self ) {
> s_self =3D new RealFactory();
> }
>
> return s_self;
>}
>
>But when PublicFactory::createPartObject() gets executed, ::self =
>returns a =
>non-NULL pointer, but the _vptr of ::s_self is NULL! This causes a =
>segfault. =
>s_self is not be deleted anywhere else, this was the first thing that I =
>looked for.
>
>Under what circumstances would _vptr be NULL?
>
>Thanks.
>-- =
>
>Craig Howard
>craig@choward.ca
>Bachelor of Math - Computer Science 2005
>University of Waterloo
> =
>>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to =
>unsubscribe <<
=
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=
e <<