Skip to content

Do nothing on paste when the clipboard has no mime data - #572

Merged
paceholder merged 2 commits into
masterfrom
fix-paste-null-mimedata
Nov 30, 2026
Merged

paceholder merged 2 commits into
masterfrom
fix-paste-null-mimedata

Conversation

@paceholder

Copy link
Copy Markdown
Owner

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation/refactoring

Description

PasteCommand::takeSceneJsonFromClipboard() used the result of QClipboard::mimeData() without a null check. Qt documents that it can return nullptr. On a platform that returns no data, for example offscreen after a clear, the paste crashed with SIGSEGV. The function now returns an empty object. The paste command becomes obsolete, as it does when the clipboard holds no nodes.

The second commit adds a test for #428. The connection of a node graphics object to nodeFlagsUpdated already has the object as its context, so the old crash no longer happens. The test checks that a cleared scene leaves no listener on the model. It fails when the context object is removed. It does not change the behavior.

Testing

Not tested: a real clipboard on a desktop platform.

Breaking changes?

No.

Related issue

Fixes #555. See also #428 (the test only).

QClipboard::mimeData() can return a null pointer. The paste command used it without a check.

Fixes #555
The connection of a node graphics object now has the object as its context, so it ends with the object. This test keeps it so. See #428.
@paceholder
paceholder merged commit c88c9b8 into master Nov 30, 2026
5 checks passed
@paceholder
paceholder deleted the fix-paste-null-mimedata branch December 1, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paste crashes when the clipboard returns no mime data

1 participant