A Qt replacement for KGlobal::ref and deref
Thiago Macieira
thiago at kde.org
Thu Feb 10 08:14:40 GMT 2011
On Wednesday, 9 de February de 2011 21:01:09 Stephen Kelly wrote:
> I asked Thiago if I the patch would be applied if I wrote one for
> QCoreApplication to fill the role instead, so that we could do
> s/KGlobal::ref/qApp->ref/g in KDE, and QCoreApplication::ref and deref would
> fill the role that the KGlobal methods currently do, and QMainWindow (or
> maybe all top level QWidgets) would use them.
>
> Obviously there would need to be more thought into how it would react with
> setQuitOnLastWindowClosed etc, but it doesn't matter because Thiago said the
> patch would not be applied. The argument against it was that if the last
> window of a gui app is closed, the app should quit and any running jobs
> should be either completed by then or terminated before the last window is
> allowed to be closed. Thiago thought that ref/deref were a bad idea in the
> first place and shouldn't be in Qt. I disagree, but there you have it.
Well, first of all, Thiago is not the highest authority in Qt. You just had my
opinion, not of all people.
Second: I don't think this should be in QCoreApplication unless there's a
*much* better control of it. It would have to be used automatically by all
top-level windows and it would have to be in-sync with
setQuitOnLastWindowClosed -- in other words, ref() should be at least the
number of top-level windows opened and maybe + 1.
My argument against this solution is that when I tell the application to Quit,
I expect it to do it. I certainly don't expect it to continue running in the
background until certain services finish running, in the background. There are
two problems with this: imagine the case of trying to upload my file to a
server while my connection is down. First of all, the application continues
running after I told it to quit. Second, I don't see the fact that there's an
important upload running.
The correct way to solve this problem is to show another window indicating
that it is doing something and tell me what. We solve both problems at once:
there is a window open, so it's not yet a quit from QCoreApplication's sense,
and the user gets feedback.
> Thiago did also offer the solution of a separate service providing the
> refcounted quit functionality, but the problem with that is that all
> libraries and applications need to use the same ref/deref code otherwise it
> won't work. If I create a separate library with a service providing that
> functionality it wouldn't help because there would be no guarantee that all
> apps and libraries would use it. The solution would need to be in Qt. It
> works in KDE of course because all KDE libraries and applications use
> KGlobal::ref and deref, which perpetuates our walled garden.
They already do. The KGlobal::ref()/deref() function is already separate and
all libraries need to use it.
Unless you can come up with a good integration with the window count, it will
be a separate solution *anyway*.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20110210/31bb323b/attachment.sig>
More information about the kde-core-devel
mailing list