mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-02 15:55:39 +00:00
Fix unresponsive GUI on quit if a polling operation is in progress
This commit is contained in:
parent
7c3f09c70c
commit
2354a0a640
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#define SER_HOSTS "hosts"
|
#define SER_HOSTS "hosts"
|
||||||
|
|
||||||
@ -161,6 +162,13 @@ ComputerManager::ComputerManager(QObject *parent)
|
|||||||
m_KnownHosts[computer->uuid] = computer;
|
m_KnownHosts[computer->uuid] = computer;
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
|
// To quit in a timely manner, we must block additional requests
|
||||||
|
// after we receive the aboutToQuit() signal. This is neccessary
|
||||||
|
// because NvHTTP uses aboutToQuit() to abort requests in progres
|
||||||
|
// while quitting, however this is a one time signal - additional
|
||||||
|
// requests would not be aborted and block termination.
|
||||||
|
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(handleAboutToQuit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputerManager::~ComputerManager()
|
ComputerManager::~ComputerManager()
|
||||||
@ -343,6 +351,17 @@ void ComputerManager::deleteHost(NvComputer* computer)
|
|||||||
QThreadPool::globalInstance()->start(new DeferredHostDeletionTask(this, computer));
|
QThreadPool::globalInstance()->start(new DeferredHostDeletionTask(this, computer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComputerManager::handleAboutToQuit()
|
||||||
|
{
|
||||||
|
QWriteLocker lock(&m_Lock);
|
||||||
|
|
||||||
|
// Interrupt polling threads immediately, so they
|
||||||
|
// avoid making additional requests while quitting
|
||||||
|
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||||
|
entry->interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PendingPairingTask : public QObject, public QRunnable
|
class PendingPairingTask : public QObject, public QRunnable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -161,6 +161,8 @@ signals:
|
|||||||
void quitAppCompleted(QVariant error);
|
void quitAppCompleted(QVariant error);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void handleAboutToQuit();
|
||||||
|
|
||||||
void handleComputerStateChanged(NvComputer* computer);
|
void handleComputerStateChanged(NvComputer* computer);
|
||||||
|
|
||||||
void handleMdnsServiceResolved(MdnsPendingComputer* computer, const QHostAddress& address);
|
void handleMdnsServiceResolved(MdnsPendingComputer* computer, const QHostAddress& address);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user