UI: Split out Whats New dialog, fix crash on shutdown

CEF crashes on shutdown if any browser window remains open during the
shutdown flow. Reproducible 100% of the time on Linux with What's New.
The previous implementation of the What's New dialog correctly deleted
all the Qt widgets, but the CEF internal event flow would only call the
"preparing to close" function, and never the "window safely closed"
function. Moving the code (practically unchanged) to a custom QDialog
solves the problem entirely, and is more consistent with other uses.
This commit is contained in:
Matt Gajownik
2024-10-19 14:51:34 +11:00
committed by Ryan Foster
parent 2e075f7513
commit 0eef4e25ee
4 changed files with 102 additions and 29 deletions

View File

@@ -68,6 +68,7 @@
#include "window-youtube-actions.hpp"
#include "youtube-api-wrappers.hpp"
#endif
#include "window-whats-new.hpp"
#include "context-bar-controls.hpp"
#include "obs-proxy-style.hpp"
#include "display-helpers.hpp"
@@ -128,6 +129,8 @@ void DestroyPanelCookieManager();
namespace {
QPointer<OBSWhatsNew> obsWhatsNew;
template<typename OBSRef> struct SignalContainer {
OBSRef ref;
vector<shared_ptr<OBSSignal>> handlers;
@@ -2544,37 +2547,11 @@ void OBSBasic::ShowWhatsNew(const QString &url)
if (closing)
return;
std::string info_url = QT_TO_UTF8(url);
QDialog *dlg = new QDialog(this);
dlg->setAttribute(Qt::WA_DeleteOnClose, true);
dlg->setWindowTitle("What's New");
dlg->resize(700, 600);
Qt::WindowFlags flags = dlg->windowFlags();
Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint;
dlg->setWindowFlags(flags & (~helpFlag));
QCefWidget *cefWidget = cef->create_widget(nullptr, info_url);
if (!cefWidget) {
return;
if (obsWhatsNew) {
obsWhatsNew->close();
}
connect(cefWidget, &QCefWidget::titleChanged, dlg, &QDialog::setWindowTitle);
QPushButton *close = new QPushButton(QTStr("Close"));
connect(close, &QAbstractButton::clicked, dlg, &QDialog::accept);
QHBoxLayout *bottomLayout = new QHBoxLayout();
bottomLayout->addStretch();
bottomLayout->addWidget(close);
bottomLayout->addStretch();
QVBoxLayout *topLayout = new QVBoxLayout(dlg);
topLayout->addWidget(cefWidget);
topLayout->addLayout(bottomLayout);
dlg->show();
obsWhatsNew = new OBSWhatsNew(this, QT_TO_UTF8(url));
#else
UNUSED_PARAMETER(url);
#endif