From 213ce75328a8fda618b74f197c30832209e7724b Mon Sep 17 00:00:00 2001 From: Ilya Melamed Date: Fri, 10 Feb 2023 14:52:15 +0300 Subject: [PATCH] UI: Add check for null widgetForAction result In some cases, `QToolbar::widgetForAction` may return `nullptr`. This causes a crash on affected system. To mitigate this, we check for `widgetForAction` result and skip operating on a NULL widget. --- UI/qt-wrappers.cpp | 4 ++++ UI/window-basic-main.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/UI/qt-wrappers.cpp b/UI/qt-wrappers.cpp index 4a89dc8fc..030ecbeae 100644 --- a/UI/qt-wrappers.cpp +++ b/UI/qt-wrappers.cpp @@ -412,6 +412,10 @@ void RefreshToolBarStyling(QToolBar *toolBar) { for (QAction *action : toolBar->actions()) { QWidget *widget = toolBar->widgetForAction(action); + + if (!widget) + continue; + widget->style()->unpolish(widget); widget->style()->polish(widget); } diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index f8fe21d1a..2a417017c 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -587,6 +587,9 @@ void OBSBasic::copyActionsDynamicProperties() for (QAction *x : ui->scenesToolbar->actions()) { QWidget *temp = ui->scenesToolbar->widgetForAction(x); + if (!temp) + continue; + for (QByteArray &y : x->dynamicPropertyNames()) { temp->setProperty(y, x->property(y)); } @@ -595,6 +598,9 @@ void OBSBasic::copyActionsDynamicProperties() for (QAction *x : ui->sourcesToolbar->actions()) { QWidget *temp = ui->sourcesToolbar->widgetForAction(x); + if (!temp) + continue; + for (QByteArray &y : x->dynamicPropertyNames()) { temp->setProperty(y, x->property(y)); } @@ -603,6 +609,9 @@ void OBSBasic::copyActionsDynamicProperties() for (QAction *x : ui->mixerToolbar->actions()) { QWidget *temp = ui->mixerToolbar->widgetForAction(x); + if (!temp) + continue; + for (QByteArray &y : x->dynamicPropertyNames()) { temp->setProperty(y, x->property(y)); }