From b92b54de0ed108e24c9311cfa3c007434a096822 Mon Sep 17 00:00:00 2001 From: pjcreath Date: Sun, 9 Nov 2025 14:20:58 -0500 Subject: [PATCH] Gui: prevent native macOS color picker crash. Fixes #25153 --- src/Gui/Widgets.cpp | 6 ++++++ src/Gui/propertyeditor/PropertyItemDelegate.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 14c78e59dd..aab896e269 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -749,8 +749,14 @@ void ColorButton::showModal() setColor(currentColor); Q_EMIT changed(); } + setProperty("modal_dialog_active", false); }); + /* A FocusOut event is sent when a native macOS color picker is opened, which + * closes the editor and destroys this object. Set a property to ignore this event. + */ + setProperty("modal_dialog_active", true); + dlg->exec(); } diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.cpp b/src/Gui/propertyeditor/PropertyItemDelegate.cpp index 87673c2ed2..7b1116fbd6 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.cpp +++ b/src/Gui/propertyeditor/PropertyItemDelegate.cpp @@ -195,6 +195,12 @@ bool PropertyItemDelegate::eventFilter(QObject *o, QEvent *ev) } } else if (ev->type() == QEvent::FocusOut) { + if (auto button = qobject_cast(o)) { + // Ignore the event if the ColorButton's modal dialog is active. + if (button->property("modal_dialog_active").toBool()) { + return true; + } + } auto parentEditor = qobject_cast(this->parent()); if (auto* comboBox = qobject_cast(o)) { if (parentEditor && parentEditor->activeEditor == comboBox) {