Navigation.remove_all() räumt Toolbar/Menü beim Unload tatsächlich auf (#72)
remove_toolbar()/remove_menu() nahmen Toolbar und Menü bisher nur aus der sichtbaren Leiste, das Qt-Objekt blieb als Kind von main_window bestehen. Beim Neuladen mit dem Plugin Reloader meldete QGIS deshalb "removing duplicated widget(s) not cleaned up by the plugin during unload: LnoSachsenToolbar" - der defensive Workaround in init_ui() (Suche nach übrig gebliebenen Toolbars) kaschierte das nur beim nächsten Laden, nicht beim Unload selbst. remove_all() ruft jetzt deleteLater() auf beide Objekte, bevor die Referenzen verworfen werden - dieselbe Behandlung, die init_ui() schon für Altlasten nutzt. deleteLater() ist in PyQt5 und PyQt6 identisch, keine QGIS3/4-Fallunterscheidung nötig. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -491,18 +491,20 @@ except (ImportError, AttributeError):
|
||||
class _MockMenu:
|
||||
def __init__(self, *args, **kwargs): self._actions = []
|
||||
def addAction(self, action): self._actions.append(action)
|
||||
def removeAction(self, action):
|
||||
def removeAction(self, action):
|
||||
if action in self._actions: self._actions.remove(action)
|
||||
def clear(self): self._actions.clear()
|
||||
def menuAction(self): return self
|
||||
def deleteLater(self) -> None: pass
|
||||
|
||||
class _MockToolBar:
|
||||
def __init__(self, *args, **kwargs): self._actions = []
|
||||
def setObjectName(self, name: str) -> None: pass
|
||||
def addAction(self, action): self._actions.append(action)
|
||||
def removeAction(self, action):
|
||||
def removeAction(self, action):
|
||||
if action in self._actions: self._actions.remove(action)
|
||||
def clear(self): self._actions.clear()
|
||||
def deleteLater(self) -> None: pass
|
||||
|
||||
class _MockActionGroup:
|
||||
def __init__(self, *args, **kwargs): self._actions = []
|
||||
|
||||
Reference in New Issue
Block a user