mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-13 02:41:16 +00:00
fix(imex): code-review nits — null check, cache-key precision, lambda capture
Four quick-fix items surfaced by pre-PR self-review.
GCodeViewer.cpp:1607
Null-check get_curr_plate() before dereferencing. Other call sites in
the file already guard; this was the only unguarded one in the IMEX
layer-preview path. In practice m_plate_list always has a plate, but
the inconsistency is easy to fix and removes the only ungated deref.
PartPlate.cpp:build_imex_cache_key
Cache key for IMEX zone geometry truncated nozzle_clearance_x/y to int
before stringifying — a config change from 30.0 to 30.5 would not
invalidate the cache. Match the *10 precision pattern already used for
imex_carriage_margin so 0.1 mm steps invalidate correctly.
Plater.cpp:select_plate_by_hover_id (right-click popup)
Two issues:
1. Lambda captured `modes` by reference. PopupMenu() is synchronous
today so the reference outlived the menu's event handling, but the
pattern is fragile — anyone refactoring to async Popup() would
silently dangle. Capture by value.
2. Used wxID_HIGHEST + i for menu item IDs — standard wx anti-pattern
because it can collide with other handlers listening in that range.
Allocate per-item IDs via wxNewId() and look up the chosen mode by
finding the event ID in a parallel vector. The lookup becomes O(N)
instead of O(1) but N is small (mode count) and this is clicker
latency, not a hot path.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
7b9070d521
commit
efa9d65cb4
@@ -933,8 +933,8 @@ std::string PartPlate::build_imex_cache_key() const
|
||||
return active_mode
|
||||
+ "|" + std::to_string(n_col_opt ? n_col_opt->value : 2)
|
||||
+ "x" + std::to_string(n_row_opt ? n_row_opt->value : 1)
|
||||
+ "|cw" + std::to_string(cw_opt ? (int)cw_opt->value : 0)
|
||||
+ "|ch" + std::to_string(ch_opt ? (int)ch_opt->value : 0)
|
||||
+ "|cw" + std::to_string(cw_opt ? (int)(cw_opt->value * 10) : 0)
|
||||
+ "|ch" + std::to_string(ch_opt ? (int)(ch_opt->value * 10) : 0)
|
||||
+ "|mg" + std::to_string(mgn_opt ? (int)(mgn_opt->value * 10) : 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user