dwg_next_handle: scan all objects for the max, as the comment promises - #1382
Open
tuxiasumari wants to merge 1 commit into
Open
dwg_next_handle: scan all objects for the max, as the comment promises#1382tuxiasumari wants to merge 1 commit into
tuxiasumari wants to merge 1 commit into
Conversation
The loop took the handle of the LAST object with a nonzero handle and stopped. That is only the maximum when objects happen to be appended in increasing handle order; during a DXF import they are not (pre-created table objects carry high handles before the file's own low handles arrive), so freshly created objects got handles already in use: ERROR: Duplicate handle 1F for object 43 already points to object 0 and the emitted DWG's object map pointed two objects at one handle.
tuxiasumari
force-pushed
the
fix-next-handle-max
branch
from
August 11, 2026 15:18
4c2e47a to
314af3e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Importing an R12 DXF (its own handles present,
$HANDLING1):and the emitted DWG's object map points two objects at one handle, so readers resolve the wrong objects.
Root cause
dwg_next_handle's comment says "check the objects for the highest handle" — but the loop takes the handle of the last object with a nonzero handle and stops:That is only the maximum when objects are appended in increasing handle order. During a DXF import they are not: pre-created table objects carry high handles (0x1F, ...) before the file's own low handles arrive, so fresh objects get handles already in use.
Fix
Scan all objects for the true maximum, matching the comment and the refs pass below it (which already scans everything).
make checkgreen; 1657-file real-DWG corpus unchanged.