Merge pull request #6063 from ligfx/queuemethodonobject
Qt QueueOnObject/RunOnObject: accept pointers to member functions
This commit is contained in:
commit
764e058865
|
@ -877,7 +877,7 @@ void MainWindow::OnImportNANDBackup()
|
||||||
.arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000));
|
.arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
QueueOnObject(dialog, [dialog] { dialog->close(); });
|
QueueOnObject(dialog, &QProgressDialog::close);
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
|
|
|
@ -405,7 +405,7 @@ void NetPlayDialog::StopGame()
|
||||||
|
|
||||||
void NetPlayDialog::Update()
|
void NetPlayDialog::Update()
|
||||||
{
|
{
|
||||||
QueueOnObject(this, [this] { UpdateGUI(); });
|
QueueOnObject(this, &NetPlayDialog::UpdateGUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetPlayDialog::DisplayMessage(const QString& msg, const std::string& color, int duration)
|
void NetPlayDialog::DisplayMessage(const QString& msg, const std::string& color, int duration)
|
||||||
|
@ -524,7 +524,7 @@ void NetPlayDialog::OnTraversalError(TraversalClient::FailureReason error)
|
||||||
|
|
||||||
bool NetPlayDialog::IsRecording()
|
bool NetPlayDialog::IsRecording()
|
||||||
{
|
{
|
||||||
return RunOnObject(this, [this] { return m_record_input_box->isChecked(); });
|
return RunOnObject(m_record_input_box, &QCheckBox::isChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NetPlayDialog::FindGame(const std::string& game)
|
std::string NetPlayDialog::FindGame(const std::string& game)
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
// arbitrary code from non-GUI threads. For more information, see:
|
// arbitrary code from non-GUI threads. For more information, see:
|
||||||
// https://stackoverflow.com/questions/21646467/
|
// https://stackoverflow.com/questions/21646467/
|
||||||
|
|
||||||
template <typename F>
|
template <typename T, typename F>
|
||||||
static void QueueOnObject(QObject* obj, F&& func)
|
static void QueueOnObject(T* obj, F&& func)
|
||||||
{
|
{
|
||||||
QObject src;
|
QObject src;
|
||||||
QObject::connect(&src, &QObject::destroyed, obj, std::forward<F>(func), Qt::QueuedConnection);
|
QObject::connect(&src, &QObject::destroyed, obj, std::forward<F>(func), Qt::QueuedConnection);
|
||||||
|
|
|
@ -33,3 +33,9 @@ auto RunOnObject(QObject* object, F&& functor)
|
||||||
event.Wait();
|
event.Wait();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Base, typename Type, typename Receiver>
|
||||||
|
auto RunOnObject(Receiver* obj, Type Base::*func)
|
||||||
|
{
|
||||||
|
return RunOnObject(obj, [obj, func] { return (obj->*func)(); });
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue