Bug 45885 - Kdevelop MDI wizard generates incorrect code for slotFileQuit() method
Summary: Kdevelop MDI wizard generates incorrect code for slotFileQuit() method
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: kdevelop 2.x (obsolete) (show other bugs)
Version: 2.1
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KDevelop-Devel List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-29 04:03 UTC by dragon
Modified: 2002-12-01 16:11 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dragon 2002-07-29 03:58:46 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kdevelop
Version:           2.1 (using KDE 3.0.0 )
Severity:          normal
Installed from:    Red Hat Linux 7.2.93
Compiler:          gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)
OS:                Linux (i686) release 2.4.18-5
OS/Compiler notes: 

The code generated by kdevelop MDI KDE wizard for the method has a programing error
The following loop is the problem:

for(w=memberList->first(); w!=0; w=memberList->first())
It nevers end.

I find that if I replace the code with
    for(w=memberList->first(); w!=0; w=memberList->next())

The my program will exit.

The following is the current code being generated by the KDE MDI wizard


void Junk2App::slotFileQuit()
{
  slotStatusMsg(i18n("Exiting..."));
  saveOptions();
  // close the first window the list makes the next one the first again.
  // This ensures that queryClose() is called on each window to ask for closing
  KMainWindow* w;
  if(memberList)
  {
    for(w=memberList->first(); w!=0; w=memberList->first())
    {
      // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog
      // the window and the application stay open.
      if(!w->close())
        break;
    }
  }
  slotStatusMsg(i18n("Ready."));
}


(Submitted via bugs.kde.org)
(Called from KBugReport dialog)
Comment 1 John Firebaugh 2002-09-22 09:22:05 UTC
Not a problem with Gideon 
Comment 2 Rosbacke 2002-12-01 16:11:10 UTC
This only fixes the problem for qt3 but introduces a new bug for  qt2. The original code depend on ~KMainWindow to be called (The closed  widget must be deleted) to iterate over memberList. This is probably  OK for qt2 but in qt3, the deletions are post-poned and the loop never   iterates over the windows.  However, using qt2 with the suggested fix would result in iterating   over every second window which I would consider a bug (not confirmed).  I would suggest the following code:        QList<KMainWindow> tList(*memberList);      for(w=tList.first(); w!=0; w=tList.next())        {  	// only close the window if the closeEvent is accepted. If the user  presses Cancel on the saveModified() dialog,  	// the window and the application stay open.  	if(!w->close())  	  break;        }    To replace the original code:        for(w=memberList->first(); w!=0; w=memberList->first())      {        // only close the window if the closeEvent is accepted. If the user  presses Cancel on the saveModified() dialog,        // the window and the application stay open.        if(!w->close())  	break;      }    //------------    This would work with both qt2 and qt3.   --- Mikael Rosbacke (rosbacke(at)nada.kth.se)