Fix type of SelectionPass

Contributes to issue CURA-5330.
This commit is contained in:
Ghostkeeper 2018-06-15 13:20:20 +02:00
parent fe43219e34
commit 1789a8f33e
No known key found for this signature in database
GPG Key ID: 5252B696FB5E7C7A

View File

@ -2,7 +2,6 @@
# Cura is released under the terms of the LGPLv3 or higher.
import copy
import json
import os
import sys
import time
@ -14,7 +13,8 @@ from PyQt5.QtGui import QColor, QIcon
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType
from UM.Qt.QtApplication import QtApplication
from typing import cast, TYPE_CHECKING
from UM.Scene.SceneNode import SceneNode
from UM.Scene.Camera import Camera
from UM.Math.Vector import Vector
@ -28,6 +28,8 @@ from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Mesh.ReadMeshJob import ReadMeshJob
from UM.Logger import Logger
from UM.Preferences import Preferences
from UM.Qt.QtApplication import QtApplication #The class we're inheriting from.
from UM.View.SelectionPass import SelectionPass #For typing.
from UM.Scene.Selection import Selection
from UM.Scene.GroupDecorator import GroupDecorator
from UM.Settings.ContainerStack import ContainerStack
@ -109,8 +111,7 @@ from UM.FlameProfiler import pyqtSlot
numpy.seterr(all = "ignore")
MYPY = False
if not MYPY:
if TYPE_CHECKING:
try:
from cura.CuraVersion import CuraVersion, CuraBuildType, CuraDebugMode
except ImportError:
@ -1719,7 +1720,7 @@ class CuraApplication(QtApplication):
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.
if not Selection.hasSelection():
node = self.getController().getScene().findObject(self.getRenderer().getRenderPass("selection").getIdAtPosition(x, y))
node = cast(SelectionPass, self.getController().getScene().findObject(self.getRenderer().getRenderPass("selection"))).getIdAtPosition(x, y)
if node:
while(node.getParent() and node.getParent().callDecoration("isGroup")):
node = node.getParent()