On Tue, Mar 26, 2013 at 11:29 AM, Jörg Ehrichs <span dir="ltr"><<a href="mailto:Joerg.Ehrichs@gmx.de" target="_blank">Joerg.Ehrichs@gmx.de</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

> [...]<br>
<div class="im">><br>
> These things should really be async.<br>
><br>
> Especially if there can be multiple services that you have no control about,<br>
> they will hang at some point, and then your UI is blocked -- never a good<br>
> thing.<br>
><br>
> We've had a non-funny amount of UI problems due to sync calls across IPC, or<br>
> into Nepomuk (and sometimes both), and it gets you a blocking UI, and it<br>
> really deteriorate the user experience.<br>
><br>
<br>
</div>I agree, I have already changed all calls to use the async dbus api instead.<br>
So blocking the UI shouldn't be a problem anymore.<br></blockquote><div><br></div><div>Nicely done! I did a quick look over the code and you're still using</div><div><br></div>QDBusConnection::sessionBus().interface()->isServiceRegistered</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">which unfortunately is a blocking DBus call. You can however replace it with something like</div><div class="gmail_quote"><br></div><div class="gmail_quote">QDBusPendingCall async = QDBusConnection::sessionBus().interface()->asyncCall(QLatin1String("NameHasOwner"), QLatin1String("org.kde.NepomukServer"));</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this);</div><div class="gmail_quote">connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),</div>

<div class="gmail_quote">this, SLOT(serviceNameFetchFinished(QDBusPendingCallWatcher*)));</div><div class="gmail_quote"><br></div><div class="gmail_quote">and in serviceNameFetchFinished you do:</div><div class="gmail_quote">

<br></div><div class="gmail_quote">::serviceNameFetchFinished(QDBusPendingCallWatcher *callWatcher) {</div><div class="gmail_quote">  QDBusPendingReply<bool> reply = *callWatcher;     </div><div class="gmail_quote">

  if (reply.isError()) { return; }</div><div class="gmail_quote">  bool isRegistered = reply.value();</div><div class="gmail_quote">  callWatcher->deleteLater();</div><div class="gmail_quote"><br></div><div class="gmail_quote">

And you're done.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">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.</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">Cheers</div>-- <br><div><span style="color:rgb(102,102,102)">Martin Klapetek | KDE Developer</span></div>