Review Request: Avoid QDBusConnection Qt warning message for each KUniqueApplication

Martin Koller kollix at aon.at
Sun Jan 15 17:28:28 GMT 2012


On Sunday, 15. January 2012 13:18:58 Thiago Macieira wrote:
> On Sunday, 15 de January de 2012 11.47.10, Martin Koller wrote:
> >    *    if (!KUniqueApplication::start()) {
> >    *       fprintf(stderr, "myAppName is already running!\n");
> >    *       return 0;
> >    *    }
> >    *    KUniqueApplication a;
> >    *    return a.exec();
> > 
> > So one of the very first things the static start() method does is to
> > open the session dbus, and this is before a QCoreApplication is available.
> 
> It should open a session bus connection, but not *the* 
> QDBusConnection::sessionBus() connection.
> 
> I know I designed the code like that. You can't open it before because that 
> would mean the file descriptor is opened in the wrong process. So where is the 
> warninig coming from?

qWarning is in QDBusDefaultConnection ctor

> Did I place the warning in the wrong object in QtDBus? 
> Or is there something *else* creating that connection?

no, it's the call to QDBusConnection::sessionBus()
which creates the QDBusDefaultConnection object which throws that warning.

> Your description still requires the QCoreApplication object to be created 
> before the fork. It doesn't matter that you're going to close that open and 
> open a new one after the fork: it's still a bad idea. Some Unix operations do 
> not survive forks, like creation of threads. If you do that, I'm pretty sure 
> QProcess will be irreparably broken.

Sorry, I don't understand that.
Nevertheless, I tried now what you've suggested above, namely to create my own
QDBusConnection object to the session bus. This seems to work now, however
as I'm new to DBus, I do not fully understand everything.
What I've found out is that the KUniqueApplication's DBus call to /MainApplication
only works if I create a QDBusConnection object on the session bus only if it
uses the same name as the Qt-internal QDBusDefaultConnection object, which is
"qt_default_session_bus", even when I would create my QDBusConnection objects
in the way that they live as long as the app lives.
Does that mean that a registered Object on DBus is linked to the QDBusConnection's name ?

I've updated the diff https://git.reviewboard.kde.org/r/103699/diff/2/
-- 
Best regards/Schöne Grüße

Martin
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

Geschenkideen, Accessoires, Seifen, Kulinarisches: www.bibibest.at
-------------- 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/20120115/37258210/attachment.sig>


More information about the kde-core-devel mailing list