Files
obs-studio/frontend/docks/OBSDock.cpp
Warchamp7 14572498dc frontend: Adjust application shutdown logic
Improves app shutdown in a few ways, including separating out different
pieces of the OBSBasic close handler into their own functions.

Removes the crash handler sentinel earlier when the main window is closed,
preventing unclean shutdown warnings when a plugin causes issues. While not
ideal, the dialog is not useful when we cannot specify which plugin caused the
problem.

Increases shutdown priority of the main application so that when OBS interrupts
the session ending, CEF is not closed at the same time. This fixes a crash.

Additional safeguards and event handling to try to ensure a smoother shutdown.
2025-12-01 16:40:34 -05:00

47 lines
1.2 KiB
C++

#include "OBSDock.hpp"
#include <widgets/OBSBasic.hpp>
#include <QCheckBox>
#include <QMessageBox>
#include "moc_OBSDock.cpp"
void OBSDock::closeEvent(QCloseEvent *event)
{
auto msgBox = []() {
QMessageBox msgbox(App()->GetMainWindow());
msgbox.setWindowTitle(QTStr("DockCloseWarning.Title"));
msgbox.setText(QTStr("DockCloseWarning.Text"));
msgbox.setIcon(QMessageBox::Icon::Information);
msgbox.addButton(QMessageBox::Ok);
QCheckBox *cb = new QCheckBox(QTStr("DoNotShowAgain"));
msgbox.setCheckBox(cb);
msgbox.exec();
if (cb->isChecked()) {
config_set_bool(App()->GetUserConfig(), "General", "WarnedAboutClosingDocks", true);
config_save_safe(App()->GetUserConfig(), "tmp", nullptr);
}
};
bool warned = config_get_bool(App()->GetUserConfig(), "General", "WarnedAboutClosingDocks");
if (!OBSBasic::Get()->isClosing() && !warned) {
QMetaObject::invokeMethod(App(), "Exec", Qt::QueuedConnection, Q_ARG(VoidFunc, msgBox));
}
QDockWidget::closeEvent(event);
if (widget() && event->isAccepted()) {
QEvent widgetEvent(QEvent::Type(QEvent::User + QEvent::Close));
qApp->sendEvent(widget(), &widgetEvent);
}
}
void OBSDock::showEvent(QShowEvent *event)
{
QDockWidget::showEvent(event);
}