On Monday 08 August 2011 16.28.43 Dawit A wrote: > > Apologies for still not getting it..> You stated you wanted to have a > > timeout to avoid a blocking UI, which as > > far as I understand you would also avoid if you don't create a new > > method that never blocks in the first place. > > The uri filter plugins, which are primarly used to filter user input,e.g. user > typing into a konqueror's address, are time critical for theobvious reasons. > The architecture for these plugins relies on a directsynchrounous call. See > KUriFilterPlugin in kio/kio/kurifilter.h.Perhaps looking at the parent of the > plugin classes will help clarifythe problem for you. KUriFilter loads all > allowed uri filter pluginsand filters the user input by invoking > KUriFilterPlugin::filterUri.
Ok, I understand your issue; To me there seems to be a architectural issue which you are fighting. Might be interesting to keep this in mind for kde5. The architectural issue I'm seeing is that there is a singleton which has a method to filter and it blocks until the filtering is done. This is at odds with the basic ingredient of using the network. One is blocking and can only give a result once, but the result might get better if we wait a bit longer. For example with DNS lookups. Anyway; lets make do with what we have :) Another solution for using a timeout can be something like the attached version (I didn't even try to compile it, maybe the helper object has to be moved to a _p.h file to get moc to run on it..) The problem that remains with this solution is that if you have 20 plusing that all have a timeout, your timeouts accumulate and you still get bad performance. But I don't see a way to solve that using the current architecture.
>From 09eb6196198c057245651b7057cae9c079fbeeea Mon Sep 17 00:00:00 2001 From: Thomas Zander <[email protected]> Date: Tue, 9 Aug 2011 12:32:55 +0200 Subject: [PATCH 1/2] fix typos --- kio/kio/kurifilter.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kio/kio/kurifilter.h b/kio/kio/kurifilter.h index 289b910..c773f2d 100644 --- a/kio/kio/kurifilter.h +++ b/kio/kio/kurifilter.h @@ -709,7 +709,7 @@ protected: /** * Sets the arguments and options string in @p data to @p args if any were - * found during filterting. + * found during filtering. */ void setArguments( KUriFilterData& data, const QString& args ) const; @@ -807,7 +807,7 @@ private: * "http://kde.org". * * You can also restrict the filters to be used by supplying the name of the - * filters you want to use. By defualt all available filters are used. + * filters you want to use. By default all available filters are used. * * To use specific filters, add the names of the filters you want to use to a * QStringList and invoke the appropriate filtering function. -- 1.7.1
>From f6c8ba5f390ba214172dda8faa6d00bf95414681 Mon Sep 17 00:00:00 2001 From: Thomas Zander <[email protected]> Date: Tue, 9 Aug 2011 12:51:51 +0200 Subject: [PATCH 2/2] Implement the hostinfo fetch using a mutex --- kio/kio/kurifilter.cpp | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/kio/kio/kurifilter.cpp b/kio/kio/kurifilter.cpp index 0144a2c..1049365 100644 --- a/kio/kio/kurifilter.cpp +++ b/kio/kio/kurifilter.cpp @@ -569,9 +569,30 @@ QString KUriFilterPlugin::iconNameFor(const KUrl& url, KUriFilterData::UriTypes return lookupIconNameFor(url, type); } +namespace { + class CallBack : public QObject { + Q_OBJECT + public slots: + void setInfo(const QHostInfo &info) { + hostInfo = info; + mutex.unlock(); + } + + public: + QHostInfo hostInfo; + QMutex mutex; + }; +}; + QHostInfo KUriFilterPlugin::resolveName(const QString& hostname, unsigned long timeout) const { - return KIO::HostInfo::lookupHost(hostname, timeout); + CallBack cb; + cb.mutex.lock(); + + const int id = QHostInfo::lookupHost(hostname, &cb, SLOT(setInfo(const QHostInfo&))); + cb.mutex.tryLock(timeout); + + return cb.hostInfo; } -- 1.7.1
