Commit 4afd2147 authored by David Hurka's avatar David Hurka 🐬
Browse files

ToggleActionMenu::createWidget(): Do not crash if parent is not a QToolBar

There used to be a Q_ASSERT_X that was triggered when a widget was requested
with something else than a QToolBar as parent widget.

However, when the ToggleActionMenu is added to a QMenu,
createWidget() is called with the QMenu as parent.
This case was missed to be tested, but occurs when the toolbar
is detached/moved by the user.
parent bf0642bf
Pipeline #74391 skipped
......@@ -35,11 +35,9 @@ QWidget *ToggleActionMenu::createWidget(QWidget *parent)
QToolButton *button = qobject_cast<QToolButton *>(buttonWidget);
if (!button) {
// This function is used to add a button into the toolbar.
// KActionMenu will plug itself as QToolButton.
// So, if no QToolButton was returned, this was not called the intended way.
Q_ASSERT_X(false,
"ToggleActionMenu::createWidget()",
"Parent implementation KActionMenu::createWidget() did not return a QToolButton, but ToggleActionMenu is designed for QToolButton. Did you call createWidget() manually, with something else than a QToolBar?");
// QWidgetAction::createWidget() is also called with other parents,
// e. g. when this ToggleActionMenu is added to a QMenu.
// Therefore, reaching this code path is a valid use case.
return buttonWidget;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment