Fix copy and pasting an item from bee file to another

This commit is contained in:
Rebecca Breu 2023-12-02 19:27:15 +01:00
parent 485e946d45
commit 421e0256b9
4 changed files with 13 additions and 3 deletions

View file

@ -33,8 +33,10 @@ Fixed
* Fixed a bug where the binary data of deleted images would still hang
around in the bee file.
* Fixed: The shortcut to move the BeeRef window (Ctrl + Alt + Drag)
not working on an empty scene
* The shortcut to move the BeeRef window (Ctrl + Alt + Drag)
now works on an empty scene
* Crash when copying an item from a bee file, opening a new scene and
pasting the image into it.
0.3.0 - 2023-11-23

View file

@ -49,6 +49,10 @@ class BeeGraphicsScene(QtWidgets.QGraphicsScene):
self.edit_item = None
self.crop_item = None
def clear(self):
super().clear()
self.internal_clipboard = []
def addItem(self, item):
logger.debug(f'Adding item {item}')
super().addItem(item)

View file

@ -539,7 +539,9 @@ class BeeGraphicsView(MainControlsMixin,
# See if we need to look up the internal clipboard:
data = clipboard.mimeData().data('beeref/items')
logger.debug(f'Custom data in clipboard: {data}')
if data:
if data and self.scene.internal_clipboard:
# Checking that internal clipboard exists since the user
# may have opened a new scene since copying.
self.scene.paste_from_internal_clipboard(pos)
return

View file

@ -69,6 +69,7 @@ def test_get_supported_image_formats_for_reading(view):
def test_clear_scene(view, item):
view.scene.addItem(item)
view.scene.internal_clipboard.append(item)
view.scale(2, 2)
view.translate(123, 456)
view.filename = 'test.bee'
@ -76,6 +77,7 @@ def test_clear_scene(view, item):
view.clear_scene()
assert not view.scene.items()
assert view.scene.internal_clipboard == []
assert view.transform().isIdentity()
assert view.filename is None
view.undo_stack.clear.assert_called_once_with()