Execute global search always in main thread
Otherwise the timer doesn't work and the invoke of the closure fails (BlockingSearchProvider::SearchAsync). This is because Q_ARG doesn't work well with templates and "QMetaMethod::invoke: Unable to handle unregistered datatype 'Arg'" is logged. See closure.h "void Unpack(QList<QGenericArgument>* list, const Arg& arg)" and "Closure::Call". This change was made because global search with the network remote didn't work anymore (network remote runs in a separete thread).
This commit is contained in:
parent
f6e7b02b7a
commit
bca2607850
@ -44,6 +44,8 @@ GlobalSearch::GlobalSearch(Application* app, QObject* parent)
|
|||||||
|
|
||||||
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)),
|
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)),
|
||||||
SLOT(AlbumArtLoaded(quint64, QImage)));
|
SLOT(AlbumArtLoaded(quint64, QImage)));
|
||||||
|
connect(this, SIGNAL(SearchAsyncSig(int,QString)),
|
||||||
|
this, SLOT(DoSearchAsync(int,QString)));
|
||||||
|
|
||||||
ConnectProvider(url_provider_);
|
ConnectProvider(url_provider_);
|
||||||
}
|
}
|
||||||
@ -82,6 +84,13 @@ void GlobalSearch::AddProvider(SearchProvider* provider) {
|
|||||||
|
|
||||||
int GlobalSearch::SearchAsync(const QString& query) {
|
int GlobalSearch::SearchAsync(const QString& query) {
|
||||||
const int id = next_id_++;
|
const int id = next_id_++;
|
||||||
|
|
||||||
|
emit SearchAsyncSig(id, query);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSearch::DoSearchAsync(int id, const QString& query) {
|
||||||
pending_search_providers_[id] = 0;
|
pending_search_providers_[id] = 0;
|
||||||
|
|
||||||
int timer_id = -1;
|
int timer_id = -1;
|
||||||
@ -106,8 +115,6 @@ int GlobalSearch::SearchAsync(const QString& query) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSearch::CancelSearch(int id) {
|
void GlobalSearch::CancelSearch(int id) {
|
||||||
|
@ -62,9 +62,11 @@ class GlobalSearch : public QObject {
|
|||||||
bool is_provider_usable(SearchProvider* provider) const;
|
bool is_provider_usable(SearchProvider* provider) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void SearchAsyncSig(int id, const QString& query);
|
||||||
void ResultsAvailable(int id, const SearchProvider::ResultList& results);
|
void ResultsAvailable(int id, const SearchProvider::ResultList& results);
|
||||||
void ProviderSearchFinished(int id, const SearchProvider* provider);
|
void ProviderSearchFinished(int id, const SearchProvider* provider);
|
||||||
void SearchFinished(int id);
|
void SearchFinished(int id);
|
||||||
@ -79,6 +81,7 @@ signals:
|
|||||||
void timerEvent(QTimerEvent* e);
|
void timerEvent(QTimerEvent* e);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void DoSearchAsync(int id, const QString& query);
|
||||||
void ResultsAvailableSlot(int id, SearchProvider::ResultList results);
|
void ResultsAvailableSlot(int id, SearchProvider::ResultList results);
|
||||||
void SearchFinishedSlot(int id);
|
void SearchFinishedSlot(int id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user