Skip to content

Commit a7340be

Browse files
committed
Spotify requests are now always sent from the main thread
1 parent 67304dd commit a7340be

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/services/rest/restserviceconnectorlocal.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ void RESTServiceConnectorLocal::disconnectService()
9393

9494
void RESTServiceConnectorLocal::sendRequest(RestRequest &&container, QPromise<RestReply> &&promise)
9595
{
96+
if (QThread::currentThread() != this->thread())
97+
{
98+
QMetaObject::invokeMethod(
99+
this,
100+
[this, container = std::move(container), promise = std::move(promise)]() mutable {
101+
sendRequest(std::move(container), std::move(promise));
102+
},
103+
Qt::ConnectionType::QueuedConnection);
104+
return;
105+
}
106+
96107
auto *requestor = makeRequestor();
97108
auto request = container.request();
98109

src/services/spotify/spotifyconnectorserver.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ void SpotifyConnectorServer::disconnectService()
5353

5454
void SpotifyConnectorServer::sendRequest(RestRequest &&container, QPromise<RestReply> &&promise)
5555
{
56+
if (QThread::currentThread() != this->thread())
57+
{
58+
QMetaObject::invokeMethod(
59+
this,
60+
[this, container = std::move(container), promise = std::move(promise)]() mutable {
61+
sendRequest(std::move(container), std::move(promise));
62+
},
63+
Qt::ConnectionType::QueuedConnection);
64+
return;
65+
}
66+
5667
auto request = container.options().testFlag(Services::Option::Authenticated) ? addAuthHeader(container.request())
5768
: container.request();
5869
QNetworkReply *reply = nullptr;

0 commit comments

Comments
 (0)