From 683fc7986cb482f40679d8fe8ee6c6253d74997d Mon Sep 17 00:00:00 2001 From: Pieter Hijma Date: Mon, 24 Nov 2025 20:59:20 +0100 Subject: [PATCH] Gui: Fix refresh on boolean property toggle (cherry picked from commit 63f739b2e4364e0c54c59f37d8a9864e62ea8470) --- .../propertyeditor/PropertyItemDelegate.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.cpp b/src/Gui/propertyeditor/PropertyItemDelegate.cpp index 36cf94bc60..b68c449409 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.cpp +++ b/src/Gui/propertyeditor/PropertyItemDelegate.cpp @@ -203,6 +203,8 @@ bool PropertyItemDelegate::eventFilter(QObject* o, QEvent* ev) auto parentEditor = qobject_cast(this->parent()); if (parentEditor && parentEditor->activeEditor == checkBox) { checkBox->toggle(); + // Delay valueChanged to ensure proper recomputation + QTimer::singleShot(0, this, [this]() { valueChanged(); }); } } } @@ -253,6 +255,19 @@ QWidget* PropertyItemDelegate::createEditor( parentEditor->closeEditor(); } + auto createEditor = [this, childItem, parent]() { + // Can't use a terniary here because the lambdas have different types. + if (qobject_cast(childItem)) { + // Boolean properties use a checkbox that is basically artificial + // (it is not rendered). Therefore, the callback is handled in + // eventFilter() + return childItem->createEditor(parent, []() noexcept {}); + } + return childItem->createEditor(parent, [this]() { + const_cast(this)->valueChanged(); // NOLINT + }); + }; + FC_LOG("create editor " << index.row() << "," << index.column()); QWidget* editor = nullptr; expressionEditor = nullptr; @@ -270,10 +285,7 @@ QWidget* PropertyItemDelegate::createEditor( propertyEditor = editor; } else { - editor = childItem->createEditor(parent, [this]() { - const_cast(this)->valueChanged(); // NOLINT - }); - propertyEditor = editor; + propertyEditor = editor = createEditor(); } } if (editor) {