Skip to content

Commit

Permalink
Fix traceback when calling itemsBoundingRect()
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Jul 31, 2024
1 parent 80360c0 commit 1844bc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gns3/graphics_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def setZoom(self, zoom):
self.scale(factor, factor)

# Calculate the bounding rectangle of all items
bounding_rect = self.scene.itemsBoundingRect()
bounding_rect = self.scene().itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
self.scene.setSceneRect(bounding_rect)
self.scene().setSceneRect(bounding_rect)

def setNodeGridSize(self, grid_size):
"""
Expand Down
18 changes: 12 additions & 6 deletions gns3/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,13 @@ def _zoomInActionSlot(self):
self.uiGraphicsView.scaleView(factor_in)
self._updateZoomSettings()

scene = self.uiGraphicsView.scene()

# Calculate the bounding rectangle of all items
bounding_rect = self.scene.itemsBoundingRect()
bounding_rect = scene.itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
self.scene.setSceneRect(bounding_rect)
scene.setSceneRect(bounding_rect)

def _zoomOutActionSlot(self):
"""
Expand All @@ -769,11 +771,13 @@ def _zoomOutActionSlot(self):
self.uiGraphicsView.scaleView(factor_out)
self._updateZoomSettings()

scene = self.uiGraphicsView.scene()

# Calculate the bounding rectangle of all items
bounding_rect = self.scene.itemsBoundingRect()
bounding_rect = scene.itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
self.scene.setSceneRect(bounding_rect)
scene.setSceneRect(bounding_rect)

def _zoomResetActionSlot(self):
"""
Expand All @@ -783,11 +787,13 @@ def _zoomResetActionSlot(self):
self.uiGraphicsView.resetTransform()
self._updateZoomSettings()

scene = self.uiGraphicsView.scene()

# Calculate the bounding rectangle of all items
bounding_rect = self.scene.itemsBoundingRect()
bounding_rect = scene.itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
self.scene.setSceneRect(bounding_rect)
scene.setSceneRect(bounding_rect)

def _fitInViewActionSlot(self):
"""
Expand Down

0 comments on commit 1844bc0

Please sign in to comment.