File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,8 @@ OBSBasic::OBSBasic(QWidget *parent)
328328
329329 setContextMenuPolicy (Qt::CustomContextMenu);
330330
331+ QEvent::registerEventType (QEvent::User + QEvent::Close);
332+
331333 api = InitializeAPIInterface (this );
332334
333335 ui->setupUi (this );
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ void OBSDock::closeEvent(QCloseEvent *event)
3434 }
3535
3636 QDockWidget::closeEvent (event);
37+
38+ if (widget () && event->isAccepted ()) {
39+ QEvent widgetEvent (QEvent::Type (QEvent::User + QEvent::Close));
40+ qApp->sendEvent (widget (), &widgetEvent);
41+ }
3742}
3843
3944void OBSDock::showEvent (QShowEvent *event)
Original file line number Diff line number Diff line change @@ -480,6 +480,12 @@ Functions
480480 Adds a dock with the widget to the UI with a toggle in the Docks
481481 menu.
482482
483+ When the dock is closed, a custom QEvent of type `QEvent::User + QEvent::Close `
484+ is sent to the widget to enable it to react to the event (e.g., unload elements
485+ to save resources).
486+ A generic QShowEvent is already sent by default when the widget is being
487+ shown (e.g., dock opened).
488+
483489 Note: Use :c:func: `obs_frontend_remove_dock ` to remove the dock
484490 and the id from the UI.
485491
You can’t perform that action at this time.
0 commit comments