SideFX Houdini customization package
git clone https://git.lucas.co/hou-control.git
statusbar: the menu-bar toggle in the circle popup did nothing
The action was connected to HCSession().toggleMainMenu, a bound method of
a throwaway instance. PySide holds only a weak reference to a bound
method's self, so the instance was collected with the popup's builder and
the slot never fired. A module-level function keeps the connection alive.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
python3.13libs/hc/hcstatusbar.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/python3.13libs/hc/hcstatusbar.py b/python3.13libs/hc/hcstatusbar.py
index 136b319..ca803ac 100644
--- a/python3.13libs/hc/hcstatusbar.py
+++ b/python3.13libs/hc/hcstatusbar.py
@@ -268,14 +268,21 @@ def _runAction(kwargs):
fn()
+def _toggleMainMenuBar():
+ # A module function, not HCSession().toggleMainMenu: PySide keeps only a
+ # weak reference to a bound method's instance, so a slot on a throwaway
+ # HCSession() was garbage-collected with it and the action did nothing.
+ from .hcsession import HCSession
+ HCSession().toggleMainMenu()
+
+
def buildMainMenu():
"""The popup: a toggle for Houdini's own menu bar, then every runnable
entry of the main menu definition, hc's menu included."""
- from .hcsession import HCSession
menu = hou.qt.Menu()
shown = _pref("showmenu.val", "1") == "1"
menu.addAction("Hide Main Menu Bar" if shown else "Show Main Menu Bar",
- HCSession().toggleMainMenu)
+ _toggleMainMenuBar)
menu.addSeparator()
parser = hou.qt.XMLMenuParser()
# parseString() ends in a NameError in Houdini's own code after a