On Tue, Mar 26, 2013 at 11:29 AM, Jörg Ehrichs <joerg.ehri...@gmx.de> wrote:
> > [...] > > > > These things should really be async. > > > > Especially if there can be multiple services that you have no control > about, > > they will hang at some point, and then your UI is blocked -- never a good > > thing. > > > > We've had a non-funny amount of UI problems due to sync calls across > IPC, or > > into Nepomuk (and sometimes both), and it gets you a blocking UI, and it > > really deteriorate the user experience. > > > > I agree, I have already changed all calls to use the async dbus api > instead. > So blocking the UI shouldn't be a problem anymore. > Nicely done! I did a quick look over the code and you're still using QDBusConnection::sessionBus().interface()->isServiceRegistered which unfortunately is a blocking DBus call. You can however replace it with something like QDBusPendingCall async = QDBusConnection::sessionBus().interface()->asyncCall(QLatin1String("NameHasOwner"), QLatin1String("org.kde.NepomukServer")); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this); connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(serviceNameFetchFinished(QDBusPendingCallWatcher*))); and in serviceNameFetchFinished you do: ::serviceNameFetchFinished(QDBusPendingCallWatcher *callWatcher) { QDBusPendingReply<bool> reply = *callWatcher; if (reply.isError()) { return; } bool isRegistered = reply.value(); callWatcher->deleteLater(); And you're done. There might be a possible race condition between this and QDBusServiceWatcher though (unlikely, but still), so you might want to initiate the QDBusServiceWatcher only in the "serviceNameFetchFinished" (or whatever you'll call it) slot. Cheers -- Martin Klapetek | KDE Developer
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel