From kdevelop Mon Jul 02 20:56:39 2001 From: =?iso-8859-1?q?R=FCdiger=20Kn=F6rig?= Date: Mon, 02 Jul 2001 20:56:39 +0000 To: kdevelop Subject: bug in kdevelop1.4's Qt2 MDI project template X-MARC-Message: https://marc.info/?l=kdevelop&m=99410823006386 While working on a kdevelop Qt2 mdi project I got crashes if the loading of a document failed and a new document should be created. The code in the "openDocumentFile" member function of the doc object who should do this is: doc = new QtpLgviewerDoc(); pDocList->append(doc); doc->newDocument(); // Creates an untitled window if file is 0 if(!file) { untitledCount+=1; QString fileName=QString(tr("Untitled%1")).arg(untitledCount); doc->setPathName(fileName); doc->setTitle(fileName); } // Open the file else { try{doc->openDocument(file);} catch(QString errormsg) { QMessageBox::critical(this, tr("Error !"),tr(errormsg)); delete doc; return; } } // create the window createClient(doc); This causes trouble if the document could not be loaded (exception catch), so you have a destroyed object in pDocList! To fix this, use the remove() method of pFocList: else { try{doc->openDocument(file);} catch(QString errormsg) { QMessageBox::critical(this, tr("Error !"),tr(errormsg)); pDocList->remove(doc); return; } } The constructor of the app object sets AutoDelete to true, so the object ist deleted. - to unsubscribe from this list send an email to kdevelop-request@kdevelop.org with the following body: unsubscribe »your-email-address«