-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
4 changed files
with
102 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "moc_window-whats-new.cpp" | ||
|
||
#include <QPushButton> | ||
#include <QHBoxLayout> | ||
#include <QVBoxLayout> | ||
|
||
#include "window-basic-main.hpp" | ||
|
||
#ifdef BROWSER_AVAILABLE | ||
#include <browser-panel.hpp> | ||
extern QCef *cef; | ||
#endif | ||
|
||
/* ------------------------------------------------------------------------- */ | ||
|
||
OBSWhatsNew::OBSWhatsNew(QWidget *parent, const std::string &url) : QDialog(parent) | ||
{ | ||
#ifdef BROWSER_AVAILABLE | ||
if (!cef) { | ||
return; | ||
} | ||
|
||
setWindowTitle("What's New"); | ||
setAttribute(Qt::WA_DeleteOnClose, true); | ||
resize(700, 600); | ||
|
||
Qt::WindowFlags flags = windowFlags(); | ||
Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint; | ||
setWindowFlags(flags & (~helpFlag)); | ||
|
||
OBSBasic::InitBrowserPanelSafeBlock(); | ||
|
||
cefWidget = cef->create_widget(nullptr, url); | ||
if (!cefWidget) { | ||
return; | ||
} | ||
|
||
connect(cefWidget, &QCefWidget::titleChanged, this, &OBSWhatsNew::setWindowTitle); | ||
|
||
QPushButton *close = new QPushButton(QTStr("Close")); | ||
connect(close, &QAbstractButton::clicked, this, &QDialog::accept); | ||
|
||
QHBoxLayout *bottomLayout = new QHBoxLayout(); | ||
bottomLayout->addStretch(); | ||
bottomLayout->addWidget(close); | ||
bottomLayout->addStretch(); | ||
|
||
QVBoxLayout *topLayout = new QVBoxLayout(this); | ||
topLayout->addWidget(cefWidget); | ||
topLayout->addLayout(bottomLayout); | ||
|
||
show(); | ||
#else | ||
UNUSED_PARAMETER(url); | ||
#endif | ||
} | ||
|
||
OBSWhatsNew::~OBSWhatsNew() {} | ||
|
||
void OBSWhatsNew::reject() | ||
{ | ||
#ifdef BROWSER_AVAILABLE | ||
delete cefWidget; | ||
#endif | ||
QDialog::reject(); | ||
} | ||
|
||
void OBSWhatsNew::accept() | ||
{ | ||
#ifdef BROWSER_AVAILABLE | ||
delete cefWidget; | ||
#endif | ||
QDialog::accept(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <QPointer> | ||
#include <QDialog> | ||
#include <string> | ||
|
||
class QCefWidget; | ||
|
||
class OBSWhatsNew : public QDialog { | ||
Q_OBJECT | ||
|
||
QCefWidget *cefWidget = nullptr; | ||
|
||
public: | ||
OBSWhatsNew(QWidget *parent, const std::string &url); | ||
~OBSWhatsNew(); | ||
|
||
virtual void reject() override; | ||
virtual void accept() override; | ||
}; |