Bug 33851

Summary: destructors of Toplevelwidgets of KDevelop creted Applications are not called on exit
Product: [Applications] kdevelop Reporter: O Dreyer <o.dreyer>
Component: kdevelop 2.x (obsolete)Assignee: KDevelop-Devel List <kdevelop-devel>
Status: RESOLVED INTENTIONAL    
Severity: normal    
Priority: NOR    
Version: 2.0.1   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description O Dreyer 2001-10-18 09:35:16 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kdevelop
Version:           2.0.1 (using KDE 2.2.1 )
Severity:          normal
Installed from:    SuSE
Compiler:          gcc version 2.95.3 20010315 (SuSE)
OS:                Linux (i686) release 2.4.7-4GB
OS/Compiler notes: 

In the main-function of a wizard-generated application you can find the line

return a.exec();

This means:
After leaving the main loop of the app the program will return directly  and calls not the destructor of the toplevel widget.

Please change this similar like this:

int main(int argc char *argv[])
{
  int ret;

  KAboutData aboutData( "kvncserver" I18N_NOOP("KVNCServer")
    VERSION description KAboutData::License_GPL
    "(c) 2001 Olaf Dreyer" 0 0 "o.dreyer@mwi-online.de");
  aboutData.addAuthor("Olaf Dreyer"0 "o.dreyer@mwi-online.de");
  KCmdLineArgs::init( argc argv &aboutData );
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  KApplication a;
  KVNCServer *kvncserver = new KVNCServer();
  a.setMainWidget(kvncserver);

  ret = a.exec();

  delete kvncserver;

  return ret;
}


(Submitted via bugs.kde.org)
(Called from KBugReport dialog)
Comment 1 Caleb Tennis 2002-10-10 20:04:08 UTC
I recommend, instead, doing this: 
 
KVNCServer kvncserver; 
a.setMainWidget(&kvncserver); 
return a.exec(); 
 
} 
 
now it will get deleted because it's on the stack and not on the heap.