From b365e51620d9c556cd83cc2baaacdf1eec891112 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Mon, 28 Sep 2026 18:24:38 +0300 Subject: [PATCH] fix(image): new image definitions allocate their own handle so DWG keeps them The definition took a peeked handle that the image then also received; the DWG writer dropped the shared-handle definition and reopened images lost their file. Fixes #1421 Co-Authored-By: Claude Opus 5.5 --- src/scene/entity.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scene/entity.rs b/src/scene/entity.rs index 46b8e5065..ece295bd2 100644 --- a/src/scene/entity.rs +++ b/src/scene/entity.rs @@ -1058,7 +1058,9 @@ impl Scene { return; } use codec::objects::{ImageDefinition, ObjectType}; - let def_handle = Handle::new(self.document.next_handle()); + // Allocate, not peek: a peeked handle is then handed to the image + // itself, and the DWG writer drops the definition that shares it. (#1421) + let def_handle = self.document.allocate_handle(); if self.is_recording_undo() { self.record_undo_object_before(def_handle, None); }