--Boundary-02=_chP1/YpbZLKexHP Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Monday 08 December 2003 12:56, Martijn Klingens wrote: > On Sun, 7 Dec 2003, Ingo [iso-8859-1] Kl=F6cker wrote: > > > Why not simply call kapp->ref() from the systemtray (your derived > > > class for now, the base one in kde-4 maybe), and deref in the > > > dtor? > > > > > > Then the user has to close the systray thingie by whichever way, > > > before the process exits. > > > > Hah! I'm glad I'm not the only one that makes this mistake. That's > > what I tried first after I found out about kapp->ref(). But it > > doesn't work. Now, think again and tell me why it won't work. ;-) > > > > Hint: kapp->deref() is called each time a last visible window is > > closed. And you can close a last visible window more than once. > > We had similar issues in Kopete, but there we solved it by not > closing the main window at all and instead _hiding_ it. That's exactly what we do in KMail. But KMainWindow::closeEvent() checks=20 whether the window that is being closed is the last _visible_ (=3D=3D=20 non-hidden) window. Any _hidden_ windows will not be counted. The=20 relevant code snippet: =3D=3D=3D=3D=3D int not_withdrawn =3D 0; QPtrListIterator it(*KMainWindow::memberList); for (it.toFirst(); it.current(); ++it){ if ( !it.current()->isHidden() && it.current()->isTopLevel()=20 && it.current() !=3D this ) not_withdrawn++; } =3D=3D=3D=3D=3D What you did is that you reimplemented KMainWindow::closeEvent() in=20 KopeteChatWindow so that kapp->deref() isn't called anymore. But that=20 won't help that much for KMail because in KMail a composer window might=20 really be the last window (and not only the last visible window) but in=20 Kopete a KopeteChatWindow can never exist without the KopeteWindow (may=20 it be hidden or not). Reimplementing KMainWindow::closeEvent() isn't really a good solution if=20 one just wants to get rid of the kapp->deref() in certain situations.=20 This just leads to bugs which are fixed in KMainWindow::closeEvent()=20 but not in the duplicated code. > What also may or may not help is fiddling with WDestructiveClose. > IIRC the deref is used only for destructively closed windows. This does only make sense for the main window (in order to dock/hide it=20 into the system tray instead of deleting it). Secondary windows must be=20 closed. kmainwindow.cpp doesn't contain any reference to=20 Qt::WDestructiveClose except for a comment. So KMainWindow doesn't seem=20 to care for this flag at all. Regards, Ingo --Boundary-02=_chP1/YpbZLKexHP Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQA/1PhcGnR+RTDgudgRAoUsAJ9s0NqS7Eri2o9hhmvUWULG6owpQwCfcLDK sOIZIK7K0B7mYUu0RPCKxDk= =mtVc -----END PGP SIGNATURE----- --Boundary-02=_chP1/YpbZLKexHP--