Use catchalls to skip over errors while centering views on players
Avoids crashes on badly-formed player data. Should tighten this up to only catch errors in getting the player's position. Should also add a validate function to AnvilPlayerRef (and every other ref, too?)
This commit is contained in:
parent
d10c6440ff
commit
cbd35c1605
@ -673,8 +673,9 @@ class EditorSession(QtCore.QObject):
|
||||
# --- Misplaced startup code? ---
|
||||
|
||||
def loadDone(self):
|
||||
# Called by MCEditApp after the view is on screen to make sure view.center() works correctly xxx used depth
|
||||
# buffer read for that, now what?
|
||||
# Called by MCEditApp after the view is on screen to make sure view.center() works correctly
|
||||
# xxx used depthbuffer read for that, now what?
|
||||
try:
|
||||
try:
|
||||
player = self.worldEditor.getPlayer()
|
||||
center = Vector(*player.Position) + (0, 1.8, 0)
|
||||
@ -695,9 +696,11 @@ class EditorSession(QtCore.QObject):
|
||||
except AttributeError:
|
||||
log.info("Centering on world center")
|
||||
center = self.currentDimension.bounds.origin + (self.currentDimension.bounds.size * 0.5)
|
||||
|
||||
self.editorTab.miniMap.centerOnPoint(center)
|
||||
self.editorTab.currentView().centerOnPoint(center, distance=0)
|
||||
except Exception as e:
|
||||
log.exception("Error while centering on player for world editor: %s", e)
|
||||
|
||||
|
||||
# --- Tools ---
|
||||
|
||||
|
@ -378,6 +378,7 @@ class WorldListWidget(QtGui.QDialog):
|
||||
self.chunkLoader.addClient(self.worldView)
|
||||
self.chunkLoader.chunkCompleted.connect(self.worldView.update)
|
||||
|
||||
try:
|
||||
try:
|
||||
player = worldEditor.getPlayer()
|
||||
log.info("Centering on single-player player.")
|
||||
@ -396,6 +397,9 @@ class WorldListWidget(QtGui.QDialog):
|
||||
center = dim.bounds.origin + (dim.bounds.size * 0.5)
|
||||
|
||||
self.worldView.centerOnPoint(center)
|
||||
except Exception as e:
|
||||
log.exception("Error while centering view in world list: %s", e)
|
||||
|
||||
log.info("Switched world view")
|
||||
|
||||
def setWorldView(self, worldView):
|
||||
|
Reference in New Issue
Block a user