1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-02 12:24:14 +01:00
parent b68134aaa7
commit 77edbb668e
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
3 changed files with 18 additions and 2 deletions

View File

@ -1355,7 +1355,7 @@ void Core::switchConfiguration(const QString& profile)
clearPassword(ptHistory); clearPassword(ptHistory);
toxTimer->stop(); toxTimer->stop();
Widget::getInstance()->setEnabled(false); Widget::getInstance()->setEnabledThreadsafe(false);
if (tox) { if (tox) {
toxav_kill(toxav); toxav_kill(toxav);
toxav = nullptr; toxav = nullptr;
@ -1373,7 +1373,7 @@ void Core::switchConfiguration(const QString& profile)
HistoryKeeper::getInstance()->resetInstance(); HistoryKeeper::getInstance()->resetInstance();
start(); start();
Widget::getInstance()->setEnabled(true); Widget::getInstance()->setEnabledThreadsafe(true);
} }
void Core::loadFriends() void Core::loadFriends()

View File

@ -1072,3 +1072,18 @@ QMessageBox::StandardButton Widget::showWarningMsgBox(const QString& title, cons
return QMessageBox::warning(this, title, msg, buttons); return QMessageBox::warning(this, title, msg, buttons);
} }
} }
void Widget::setEnabledThreadsafe(bool enabled)
{
// We can only do this from the GUI thread
if (QThread::currentThread() != qApp->thread())
{
QMetaObject::invokeMethod(this, "setEnabledThreadsafe", Qt::BlockingQueuedConnection,
Q_ARG(bool, enabled));
return;
}
else
{
return setEnabled(enabled);
}
}

View File

@ -66,6 +66,7 @@ public:
void setTranslation(); void setTranslation();
Q_INVOKABLE QMessageBox::StandardButton showWarningMsgBox(const QString& title, const QString& msg, Q_INVOKABLE QMessageBox::StandardButton showWarningMsgBox(const QString& title, const QString& msg,
QMessageBox::StandardButtons buttonss = QMessageBox::Ok); QMessageBox::StandardButtons buttonss = QMessageBox::Ok);
Q_INVOKABLE void setEnabledThreadsafe(bool enabled);
~Widget(); ~Widget();
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);