diff --git a/UI/auth-mixer.cpp b/UI/auth-mixer.cpp index e9fc9a94e..1f0374ce0 100644 --- a/UI/auth-mixer.cpp +++ b/UI/auth-mixer.cpp @@ -83,7 +83,7 @@ try { 5); }; - ExecuteFuncSafeBlockMsgBox( + ExecThreadedWithoutBlocking( func, QTStr("Auth.LoadingChannel.Title"), QTStr("Auth.LoadingChannel.Text").arg(service())); @@ -126,7 +126,7 @@ try { 5); }; - ExecuteFuncSafeBlockMsgBox( + ExecThreadedWithoutBlocking( func, QTStr("Auth.LoadingChannel.Title"), QTStr("Auth.LoadingChannel.Text").arg(service())); @@ -205,7 +205,7 @@ void MixerAuth::LoadUI() if (!GetChannelInfo()) return; - OBSBasic::InitBrowserPanelSafeBlock(true); + OBSBasic::InitBrowserPanelSafeBlock(); OBSBasic *main = OBSBasic::Get(); std::string url; diff --git a/UI/auth-oauth.cpp b/UI/auth-oauth.cpp index 96da460c4..0237f4784 100644 --- a/UI/auth-oauth.cpp +++ b/UI/auth-oauth.cpp @@ -34,7 +34,7 @@ OAuthLogin::OAuthLogin(QWidget *parent, const std::string &url, bool token) Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint; setWindowFlags(flags & (~helpFlag)); - OBSBasic::InitBrowserPanelSafeBlock(true); + OBSBasic::InitBrowserPanelSafeBlock(); cefWidget = cef->create_widget(nullptr, url, panel_cookies); if (!cefWidget) { @@ -216,7 +216,7 @@ try { 5); }; - ExecuteFuncSafeBlockMsgBox( + ExecThreadedWithoutBlocking( func, QTStr("Auth.Authing.Title"), QTStr("Auth.Authing.Text").arg(service())); diff --git a/UI/auth-twitch.cpp b/UI/auth-twitch.cpp index 4a52e7e40..c2b60043f 100644 --- a/UI/auth-twitch.cpp +++ b/UI/auth-twitch.cpp @@ -90,7 +90,7 @@ try { 5); }; - ExecuteFuncSafeBlockMsgBox( + ExecThreadedWithoutBlocking( func, QTStr("Auth.LoadingChannel.Title"), QTStr("Auth.LoadingChannel.Text").arg(service())); @@ -191,7 +191,7 @@ void TwitchAuth::LoadUI() if (!GetChannelInfo()) return; - OBSBasic::InitBrowserPanelSafeBlock(true); + OBSBasic::InitBrowserPanelSafeBlock(); OBSBasic *main = OBSBasic::Get(); QCefWidget *browser; diff --git a/UI/qt-wrappers.cpp b/UI/qt-wrappers.cpp index fc4d7c209..0ce9ba0bc 100644 --- a/UI/qt-wrappers.cpp +++ b/UI/qt-wrappers.cpp @@ -263,3 +263,21 @@ void ExecuteFuncSafeBlockMsgBox( dlg.exec(); thread->wait(); } + +static bool enable_message_boxes = false; + +void EnableThreadedMessageBoxes(bool enable) +{ + enable_message_boxes = enable; +} + +void ExecThreadedWithoutBlocking( + std::function func, + const QString &title, + const QString &text) +{ + if (!enable_message_boxes) + ExecuteFuncSafeBlock(func); + else + ExecuteFuncSafeBlockMsgBox(func, title, text); +} diff --git a/UI/qt-wrappers.hpp b/UI/qt-wrappers.hpp index a75ea7f7e..ef8ed32ea 100644 --- a/UI/qt-wrappers.hpp +++ b/UI/qt-wrappers.hpp @@ -73,6 +73,14 @@ void ExecuteFuncSafeBlockMsgBox( const QString &title, const QString &text); +/* allows executing without message boxes if starting up, otherwise with a + * message box */ +void EnableThreadedMessageBoxes(bool enable); +void ExecThreadedWithoutBlocking( + std::function func, + const QString &title, + const QString &text); + class SignalBlocker { QWidget *widget; bool blocked; diff --git a/UI/window-basic-auto-config.cpp b/UI/window-basic-auto-config.cpp index c367ebcb8..b3cc2b3b5 100644 --- a/UI/window-basic-auto-config.cpp +++ b/UI/window-basic-auto-config.cpp @@ -709,6 +709,8 @@ void AutoConfigStreamPage::UpdateCompleted() AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent) { + EnableThreadedMessageBoxes(true); + calldata_t cd = {0}; calldata_set_int(&cd, "seconds", 5); @@ -839,6 +841,7 @@ AutoConfig::~AutoConfig() { OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); main->EnableOutputs(true); + EnableThreadedMessageBoxes(false); } void AutoConfig::TestHardwareEncoding() diff --git a/UI/window-basic-main-browser.cpp b/UI/window-basic-main-browser.cpp index 36c87732d..3d4aa65a5 100644 --- a/UI/window-basic-main-browser.cpp +++ b/UI/window-basic-main-browser.cpp @@ -145,7 +145,7 @@ void DuplicateCurrentCookieProfile(ConfigFile &config) #endif } -void OBSBasic::InitBrowserPanelSafeBlock(bool showDialog) +void OBSBasic::InitBrowserPanelSafeBlock() { #ifdef BROWSER_AVAILABLE if (!cef) @@ -155,15 +155,10 @@ void OBSBasic::InitBrowserPanelSafeBlock(bool showDialog) return; } - if (showDialog) - ExecuteFuncSafeBlockMsgBox( - [] {cef->wait_for_browser_init();}, - QTStr("BrowserPanelInit.Title"), - QTStr("BrowserPanelInit.Text")); - else - ExecuteFuncSafeBlock( - [] {cef->wait_for_browser_init();}); - + ExecThreadedWithoutBlocking( + [] {cef->wait_for_browser_init();}, + QTStr("BrowserPanelInit.Title"), + QTStr("BrowserPanelInit.Text")); InitPanelCookieManager(); #else UNUSED_PARAMETER(showDialog); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 9d6e53578..2ee43915f 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -804,7 +804,7 @@ public: virtual int GetProfilePath(char *path, size_t size, const char *file) const override; - static void InitBrowserPanelSafeBlock(bool showDialog); + static void InitBrowserPanelSafeBlock(); private: std::unique_ptr ui; diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index b8d02aa9c..f2de99e57 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -280,6 +280,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) { string path; + EnableThreadedMessageBoxes(true); + ui->setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -735,6 +737,8 @@ OBSBasicSettings::~OBSBasicSettings() delete ui->filenameFormatting->completer(); main->EnableOutputs(true); App()->EnableInFocusHotkeys(!disableHotkeysInFocus); + + EnableThreadedMessageBoxes(false); } void OBSBasicSettings::SaveCombo(QComboBox *widget, const char *section,