mirror of
https://github.com/leozide/leocad.git
synced 2026-10-26 22:10:32 +00:00
Piece registrations were centralized but creation, reference bookkeeping and cleanup still lived in the library. Move creation/model reuse, normalization, metadata renaming, reference operations, temporary cleanup, project transfer and ordered identity teardown into the manager. Keep registration/deletion helpers private and remove the temporary local-registry enumeration APIs. The library remains the acquisition facade and coordinates source resolution, loading, invalidation and cancellation after unlocking. Handles still bind to the library. Clear sparse errors from lcPieceData::Unload before resource teardown so manager deletion does not require a library pointer or callback. Sparse error storage and the existing synchronization remain library-side. Use one project-aware manager lookup, passing nullptr for shared-only searches. Remove the maximum-size name reservation so short names can use inline storage. Replace remaining bounded C-string copy/terminator pairs with lcstrcpy and record the helper convention in common/AGENTS.md. Update the asset lifetime documentation. Validation: macOS Qt 6.10 Debug build, whitespace checks and 40 offscreen lifecycle checks, including already-zero release, last-owner cancellation, model reuse, project detach/transfer cleanup, sparse errors, archive/directory caches and forced nested external-project teardown. Successful GPU rendering is not covered by the offscreen checks.
1.8 KiB
1.8 KiB
Code instructions
- Keep the file lists in
leocad.proalphabetically sorted within their existing groups. - Get Qt and std includes through the precompiled header,
lc_global.h. - Prefer std containers, use Qt containers where a Qt API boundary makes them useful.
- Prefer
lcstrcpy()andlcstrcat()fromlc_string.hfor bounded C-string copies and concatenation. Use the array overloads when possible; avoidstrncpy()plus manual null termination. Keep standard functions where no suitablelchelper exists. - Avoid using
autofor ordinary variable types. Template iterators, lambdas, and structured bindings may use it for readability. - Do not nest ternary expressions. Use explicit branches when a choice needs another condition.
- Prefer a private static member function over a file-scope helper when the function belongs to a class and does not use instance state.
- Prefer explicit
lock()andunlock()over an extra scope withQMutexLockerfor short, straight-line critical sections that must end before the following code. KeepQMutexLockerfor early returns, waits, or nontrivial control flow. - Preserve existing blank lines when editing code. Prefer blank lines between declarations and following logic, and between distinct logical steps; do not remove user-added blank lines without a specific reason.
- When adding a parameter to an existing function, update every call site explicitly instead of adding a default argument to preserve old calls.
Commit Messages
- Every nontrivial commit must have a concise subject and a descriptive body.
- Explain the problem or trigger, why the change is needed, and how the resulting behavior addresses it.
- Write for a future maintainer without access to the chat. Do not merely restate the diff or include conversational history.
- Subject-only messages are acceptable for purely mechanical changes.