From 9ce9c6b99ab99701ee19f9fe59ee901d592adf7a Mon Sep 17 00:00:00 2001 From: David Kaufman Date: Sat, 13 Sep 2025 22:13:55 -0400 Subject: [PATCH 1/2] [CAM] replace python uses of QSignalBlocker --- src/Mod/CAM/Path/Main/Gui/Job.py | 5 +++- src/Mod/CAM/Path/Op/Gui/Base.py | 32 +++++++++++++----------- src/Mod/CAM/Path/Tool/Gui/Controller.py | 33 ++++++++++++++++--------- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/Mod/CAM/Path/Main/Gui/Job.py b/src/Mod/CAM/Path/Main/Gui/Job.py index cc76aac621..27c766e6e8 100644 --- a/src/Mod/CAM/Path/Main/Gui/Job.py +++ b/src/Mod/CAM/Path/Main/Gui/Job.py @@ -705,7 +705,8 @@ class StockFromExistingEdit(StockEdit): # dropdown list. This is important because the `currentIndexChanged` signal # will in the end result in the stock object being recreated in `getFields` # method, discarding any changes made (like position in respect to origin). - with QtCore.QSignalBlocker(self.form.stockExisting): + try: + self.form.stockExisting.blockSignals(True) self.form.stockExisting.clear() stockName = obj.Stock.Label if obj.Stock else None index = -1 @@ -716,6 +717,8 @@ class StockFromExistingEdit(StockEdit): index = i self.form.stockExisting.setCurrentIndex(index if index != -1 else 0) + finally: + self.form.stockExisting.blockSignals(False) if not self.IsStock(obj): self.getFields(obj) diff --git a/src/Mod/CAM/Path/Op/Gui/Base.py b/src/Mod/CAM/Path/Op/Gui/Base.py index b492e0a1d3..ec7a86a7fd 100644 --- a/src/Mod/CAM/Path/Op/Gui/Base.py +++ b/src/Mod/CAM/Path/Op/Gui/Base.py @@ -371,24 +371,26 @@ class TaskPanelPage(object): def selectInComboBox(self, name, combo): """selectInComboBox(name, combo) ... helper function to select a specific value in a combo box.""" - blocker = QtCore.QSignalBlocker(combo) - index = combo.currentIndex() # Save initial index + try: + combo.blockSignals(True) + index = combo.currentIndex() # Save initial index - # Search using currentData and return if found - newindex = combo.findData(name) - if newindex >= 0: - combo.setCurrentIndex(newindex) - return + # Search using currentData and return if found + newindex = combo.findData(name) + if newindex >= 0: + combo.setCurrentIndex(newindex) + return - # if not found, search using current text - newindex = combo.findText(name, QtCore.Qt.MatchFixedString) - if newindex >= 0: - combo.setCurrentIndex(newindex) - return + # if not found, search using current text + newindex = combo.findText(name, QtCore.Qt.MatchFixedString) + if newindex >= 0: + combo.setCurrentIndex(newindex) + return - # not found, return unchanged - combo.setCurrentIndex(index) - return + # not found, return unchanged + combo.setCurrentIndex(index) + finally: + combo.blockSignals(False) def populateCombobox(self, form, enumTups, comboBoxesPropertyMap): """populateCombobox(form, enumTups, comboBoxesPropertyMap) ... proxy for PathGuiUtil.populateCombobox()""" diff --git a/src/Mod/CAM/Path/Tool/Gui/Controller.py b/src/Mod/CAM/Path/Tool/Gui/Controller.py index f5712e1c71..e81a403519 100644 --- a/src/Mod/CAM/Path/Tool/Gui/Controller.py +++ b/src/Mod/CAM/Path/Tool/Gui/Controller.py @@ -230,7 +230,8 @@ class ToolControllerEditor(object): def selectInComboBox(self, name, combo): """selectInComboBox(name, combo) ... helper function to select a specific value in a combo box.""" - with QtCore.QSignalBlocker(combo): + try: + combo.blockSignals(True) index = combo.currentIndex() # Save initial index # Search using currentData and return if found @@ -247,21 +248,26 @@ class ToolControllerEditor(object): # not found, return unchanged combo.setCurrentIndex(index) - return + finally: + combo.blockSignals(False) def updateUi(self): tc = self.obj - with ( - QtCore.QSignalBlocker(self.controller.tcName), - QtCore.QSignalBlocker(self.controller.tcNumber), - QtCore.QSignalBlocker(self.horizFeed.widget), - QtCore.QSignalBlocker(self.horizRapid.widget), - QtCore.QSignalBlocker(self.vertFeed.widget), - QtCore.QSignalBlocker(self.vertRapid.widget), - QtCore.QSignalBlocker(self.controller.spindleSpeed), - QtCore.QSignalBlocker(self.controller.spindleDirection), - ): + blockObjects = [ + self.controller.tcName, + self.controller.tcNumber, + self.horizFeed.widget, + self.horizRapid.widget, + self.vertFeed.widget, + self.vertRapid.widget, + self.controller.spindleSpeed, + self.controller.spindleDirection, + ] + try: + for obj in blockObjects: + obj.blockSignals(True) + self.controller.tcName.setText(tc.Label) self.controller.tcNumber.setValue(tc.ToolNumber) self.horizFeed.updateWidget() @@ -274,6 +280,9 @@ class ToolControllerEditor(object): if self.editor: self.editor.updateUI() + finally: + for obj in blockObjects: + obj.blockSignals(False) def updateToolController(self): tc = self.obj From 2cb86f259eca5190c2cd95b3dd152fc9658edb4c Mon Sep 17 00:00:00 2001 From: David Kaufman Date: Sun, 14 Sep 2025 14:59:21 -0400 Subject: [PATCH 2/2] also add qt5 compatibility for checkbox state change signal --- src/Mod/CAM/Path/Op/Gui/Base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Mod/CAM/Path/Op/Gui/Base.py b/src/Mod/CAM/Path/Op/Gui/Base.py index ec7a86a7fd..2842adc2c5 100644 --- a/src/Mod/CAM/Path/Op/Gui/Base.py +++ b/src/Mod/CAM/Path/Op/Gui/Base.py @@ -523,9 +523,13 @@ class TaskPanelPage(object): self.updateToolControllerEditorVisibility() self.tcEditor.updateUi() - self.form.editToolController.checkStateChanged.connect( - self.updateToolControllerEditorVisibility + checkbox = self.form.editToolController + checkboxSignal = ( + checkbox.checkStateChanged + if hasattr(checkbox, "checkStateChanged") + else checkbox.stateChanged ) + checkboxSignal.connect(self.updateToolControllerEditorVisibility) if oldEditor: oldEditor.updateToolController()