[Nepomuk] Nepomukcontroller rewritten in QML
Martin Klapetek
martin.klapetek at gmail.com
Tue Mar 26 10:54:57 UTC 2013
On Tue, Mar 26, 2013 at 11:29 AM, Jörg Ehrichs <Joerg.Ehrichs at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20130326/1d914126/attachment.html>
More information about the Plasma-devel
mailing list