diff --git a/UI/win-update/win-update.cpp b/UI/win-update/win-update.cpp index 06566daec..fe2ccf65c 100644 --- a/UI/win-update/win-update.cpp +++ b/UI/win-update/win-update.cpp @@ -20,8 +20,15 @@ #include #include +#ifdef BROWSER_AVAILABLE +#include +#endif + using namespace std; +struct QCef; +extern QCef *cef; + /* ------------------------------------------------------------------------ */ #ifndef WIN_MANIFEST_URL @@ -799,3 +806,13 @@ try { } catch (string &text) { blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str()); } + +/* ------------------------------------------------------------------------ */ + +void WhatsNewBrowserInitThread::run() +{ +#ifdef BROWSER_AVAILABLE + cef->wait_for_browser_init(); +#endif + emit Result(url); +} diff --git a/UI/win-update/win-update.hpp b/UI/win-update/win-update.hpp index c1bd8fb8b..1e450a6ea 100644 --- a/UI/win-update/win-update.hpp +++ b/UI/win-update/win-update.hpp @@ -33,3 +33,17 @@ signals: public: inline WhatsNewInfoThread() {} }; + +class WhatsNewBrowserInitThread : public QThread { + Q_OBJECT + + QString url; + + virtual void run() override; + +signals: + void Result(const QString &url); + +public: + inline WhatsNewBrowserInitThread(const QString &url_) : url(url_) {} +}; diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 48f2d422a..495258afd 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -1896,6 +1896,9 @@ void OBSBasic::ReceivedIntroJson(const QString &text) { #ifdef BROWSER_AVAILABLE #ifdef _WIN32 + if (closing) + return; + std::string err; Json json = Json::parse(QT_TO_UTF8(text), err); if (!err.empty()) @@ -1970,7 +1973,33 @@ void OBSBasic::ReceivedIntroJson(const QString &text) } #endif cef->init_browser(); - ExecuteFuncSafeBlock([] { cef->wait_for_browser_init(); }); + + WhatsNewBrowserInitThread *wnbit = + new WhatsNewBrowserInitThread(QT_UTF8(info_url.c_str())); + if (wnbit) { + connect(wnbit, &WhatsNewBrowserInitThread::Result, this, + &OBSBasic::ShowWhatsNew); + } + if (wnbit) { + whatsNewInitThread.reset(wnbit); + whatsNewInitThread->start(); + } +#else + UNUSED_PARAMETER(text); +#endif +#else + UNUSED_PARAMETER(text); +#endif +} + +void OBSBasic::ShowWhatsNew(const QString &url) +{ +#ifdef BROWSER_AVAILABLE +#ifdef _WIN32 + if (closing) + return; + + std::string info_url = QT_TO_UTF8(url); QDialog *dlg = new QDialog(this); dlg->setAttribute(Qt::WA_DeleteOnClose, true); @@ -2003,10 +2032,10 @@ void OBSBasic::ReceivedIntroJson(const QString &text) dlg->show(); #else - UNUSED_PARAMETER(text); + UNUSED_PARAMETER(url); #endif #else - UNUSED_PARAMETER(text); + UNUSED_PARAMETER(url); #endif } @@ -3933,8 +3962,12 @@ void OBSBasic::closeEvent(QCloseEvent *event) blog(LOG_INFO, SHUTDOWN_SEPARATOR); + closing = true; + if (introCheckThread) introCheckThread->wait(); + if (whatsNewInitThread) + whatsNewInitThread->wait(); if (updateCheckThread) updateCheckThread->wait(); if (logUploadThread) diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index fe98474df..7d47ce286 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -193,6 +193,8 @@ private: const char *copyFiltersString = nullptr; bool copyVisible = true; + bool closing = false; + QScopedPointer whatsNewInitThread; QScopedPointer updateCheckThread; QScopedPointer introCheckThread; QScopedPointer logUploadThread; @@ -463,6 +465,7 @@ private: void LoadSavedProjectors(obs_data_array_t *savedProjectors); void ReceivedIntroJson(const QString &text); + void ShowWhatsNew(const QString &url); #ifdef BROWSER_AVAILABLE QList> extraBrowserDocks;