Skip to content

Fix node moves, locks and group crashes (3.x) - #542

Merged
paceholder merged 8 commits into
masterfrom
fix/model-driven-node-move
Nov 22, 2026
Merged

paceholder merged 8 commits into
masterfrom
fix/model-driven-node-move

Conversation

@paceholder

@paceholder paceholder commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Type of change

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

Description

Bug fixes for 3.x. No public API is removed or changed.

  • Dragging a node moves it through the model again. mouseMoveEvent pushes a MoveNodeCommand, and the scene follows the model signals. Since the node group commit (3.1.4), only the graphics item moved. nodeMoved was not emitted, setNodeData was not called and the saved position was wrong. MoveNodeCommand has a new constructor that takes node ids, so a group can move its nodes.
  • A model-locked node cannot start a connection or detach one again. The model lock and the group lock set the item flags in one place now, so one lock does not undo the other.
  • Crashes in the group lifetime: a model reset with a group, a double delete of the group item, and a node that is in two groups. Undo of a move skips nodes that no longer exist.
  • C++17 is declared for developer builds only. The README says how to set the standard in your project.
  • Docs: new page docs/migration/v3-to-v4.rst. It lists the known limits of groups in 3.x and why they are fixed in v4 (Move node groups into the model (next major version) #539). The FAQ no longer says that groups do not exist.
  • AGENTS.md and CLAUDE.md, and ignore of local directories.

#533 fixes the same move bug by syncing the graphics position into the model. This PR restores the original flow instead, where the model changes first.

Testing

  • Qt version tested: 6.12.0 (macOS, Apple Clang). The full suite also ran under AddressSanitizer without errors.
  • Existing tests still pass
  • Added tests for new functionality (if applicable)

Each fix has a test that fails without it.

Breaking changes?

None. PasteCommand has a private member that is now a value and not a reference. This changes the class layout, but not the API.

Related issue

Fixes #525. Fixes #526. Fixes #536. Fixes #540.

Refs #516, #533, #539.

@paceholder
paceholder force-pushed the fix/model-driven-node-move branch 2 times, most recently from d90b26f to d347d46 Compare November 22, 2026 16:48
Since the node group commit, dragging a node let Qt move the item and
never told the model, so NodeRole::Position stayed at the old value.
Saved positions, setNodeData overrides and nodeMoved saw stale data, and
a drag was not undoable.

Restore the original flow: mouseMoveEvent pushes a MoveNodeCommand and
the scene follows the model signals. MoveNodeCommand gets a constructor
taking explicit node ids, so group dragging can move the group's nodes
plus any selected nodes. GroupGraphicsObject::moveNodes writes to the
model without an undo command.

Remove the branch that moved the nodes of a locked group without an undo
command. A locked group is dragged through its own item.

Reset the drag flag of the scene on mouse press. A position set from code
or by undo no longer makes the next plain click emit nodeMoved.

Add tests that drag a node and a group with simulated mouse events and
check model positions, the nodeMoved signal and undo/redo.

Fixes #525
Fixes #526
Refs #533
The v1 and v2 branches are being removed. Their history is reachable
from tags 1.0 and 2.2.4, so refer to those instead of the branches.
The sources already use C++17 (if with initializer, structured bindings)
and Qt 6 requires it. Declare it for developer builds, inside the
developer-defaults block, and state it in the README.

QtNodes does not impose a standard on projects that include it. They
set their own, so that all of their targets stay consistent.

Refs #516
AGENTS.md holds the guidance for coding agents: writing style, build and
test commands, architecture, code style, C++ standard policy, test and
docs rules, and commit and release rules. CLAUDE.md imports it.
.claude/ holds personal agent settings and worktrees. openspec/ is the
maintainer's local planning space.
The node group commit replaced the NodeFlag::Locked check in
mousePressEvent with the group lock only. A model-locked node could
start a draft connection or detach a connection again.

The model lock and the group lock also wrote the same item flags.
Unlocking a group made a model-locked node selectable, and a flags
update made a node of a locked group selectable. setLockedState now
sets the flags from both locks, and lock() calls it.

Fixes #536
A model reset left the groups in the scene. The nodes were deleted first
and clear() deleted the group items, which the groups still owned. The
next use or the destruction of the scene deleted them again. Drop the
groups before anything is cleared.

addNodeToGroup did not check the current group of the node. The node was
listed twice in the same group, or stayed in the old group too. Return
if it is already a member, otherwise remove it from the old group first.

A group had the scene as QObject parent and also a shared_ptr, so it had
two owners. The scene also deleted the group items that the groups owned.
Create the group without a parent. The scene destructor releases the
group items while the scene is alive.

The undo and redo of a move skip nodes that no longer exist.

Fixes #540
The docs said that node groups are not implemented. They exist since
3.1.4. Say how to enable them.

Add a page that lists the known problems of groups in 3.x and explains
why they are fixed in v4 and not in 3.x.

Refs #539
@paceholder
paceholder force-pushed the fix/model-driven-node-move branch from d347d46 to 873a1e7 Compare November 22, 2026 16:49
@paceholder
paceholder merged commit e7cd1d0 into master Nov 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant