mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 03:09:04 +08:00
Guard against selection pass not existing yet
It could happen that the selection pass is not initialised because you're right clicking on the screen before the first render has happened. Hopefully this fixes #6976.
This commit is contained in:
parent
8bf7666493
commit
0e5654e44b
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2019 Ultimaker B.V.
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -1827,11 +1827,17 @@ class CuraApplication(QtApplication):
|
|||||||
|
|
||||||
def _onContextMenuRequested(self, x: float, y: float) -> None:
|
def _onContextMenuRequested(self, x: float, y: float) -> None:
|
||||||
# Ensure we select the object if we request a context menu over an object without having a selection.
|
# Ensure we select the object if we request a context menu over an object without having a selection.
|
||||||
if not Selection.hasSelection():
|
if Selection.hasSelection():
|
||||||
node = self.getController().getScene().findObject(cast(SelectionPass, self.getRenderer().getRenderPass("selection")).getIdAtPosition(x, y))
|
return
|
||||||
if node:
|
selection_pass = cast(SelectionPass, self.getRenderer().getRenderPass("selection"))
|
||||||
|
if not selection_pass: # If you right-click before the rendering has been initialised there might not be a selection pass yet.
|
||||||
|
print("--------------ding! Got the crash.")
|
||||||
|
return
|
||||||
|
node = self.getController().getScene().findObject(selection_pass.getIdAtPosition(x, y))
|
||||||
|
if not node:
|
||||||
|
return
|
||||||
parent = node.getParent()
|
parent = node.getParent()
|
||||||
while(parent and parent.callDecoration("isGroup")):
|
while parent and parent.callDecoration("isGroup"):
|
||||||
node = parent
|
node = parent
|
||||||
parent = node.getParent()
|
parent = node.getParent()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user