KJanusWidget problem (also with noatun/kopete): showstopper?

Martijn Klingens klingens at kde.org
Fri Nov 8 16:54:34 GMT 2002

On Friday 08 November 2002 17:10, Ravikiran Rajagopal wrote:
>----- #include <kapplication.h>
> #include <kjanuswidget.h>
> #include <qhbox.h>
> #include <qstringlist.h>
> #include <qtextedit.h>
> int main( int argc, char **argv )
> {
>   KApplication app( argc, argv, "Testing" );
>   KJanusWidget wid(0,0,KJanusWidget::TreeList);

What happens if you make this

KJanusWidget *wid = new KJanusWidget(0,0,KJanusWidget::TreeList);

and change '&wid' into 'wid' resp. 'wid.' into 'wid->' accordingly?

>   app.setMainWidget( &wid );
>   QStringList list1, list2;
>   list1 << "level1" << "page";
>   list2 << "level2" << "page";
>   QHBox *box1, *box2;
>   box1 = wid.addHBoxPage(list1);
>   new QTextEdit(box1);
>   box2 = wid.addHBoxPage(list2);
>   new QTextEdit(box2);
>   wid.show();
>   delete box1;
>   return app.exec();
> }
> ---------------------------------------------------------------------------

Also, what does valgrind output?

My suspicion is that the main widget is deleted twice here, although looking 
at my (rather old) qt-copy checkout I can't see this confirmed.

Another option is that deleting wid on shutdown goes wrong for objects on the 
stack. If you make wid a pointer and delete it, does that make a difference 
with 'leaking' the object by not deleting?

If you make the KApp a pointer instead, does it make a difference if you 
delete the app before or after the widget? In your example I wonder in what 
order both on-stack objects are deleted by the compiler. FIFO or LIFO ?

More information about the kde-multimedia mailing list