Skip to content

fix: remove duplicate CMake sources, plug timer leak, debounce idle config save#10387

Open
tinezivic wants to merge 1 commit intobambulab:masterfrom
tinezivic:fix/ui-quickwins-idle-timer-cmake
Open

fix: remove duplicate CMake sources, plug timer leak, debounce idle config save#10387
tinezivic wants to merge 1 commit intobambulab:masterfrom
tinezivic:fix/ui-quickwins-idle-timer-cmake

Conversation

@tinezivic
Copy link
Copy Markdown

@tinezivic tinezivic commented Apr 26, 2026

Fixes three small independent issues from the static analysis in #10289.

F-010 — duplicate sources in CMakeLists.txt
Scrollbar.cpp and ScrolledWindow.cpp were listed twice in SLIC3R_GUI_SOURCES. Removed the redundant entries.

F-006 — timer_sync_printer leak in Sidebar::priv::~priv()
timer_sync_printer is heap-allocated (= new wxTimer()) but the destructor never deleted it. Added Stop() + delete + null-out.

F-015 — unbounded app_config->save() in idle handler
The idle handler called app_config->save() on every dirty idle event — on a busy loop this means a synchronous disk write at idle frequency. Added a 5-second rate limit via std::chrono::steady_clock. OnExit() flushes any remaining dirty state so no settings are lost on clean shutdown.


Tests

Extracted the rate-limit logic into src/libslic3r/Debounce.hpp (pure C++, no wx dependency) and added tests/libslic3r/test_debounce.cpp with 5 Catch2 scenarios covering first call, suppression, interval expiry, zero interval, and no mutation on suppressed calls.

All tests passed (7 assertions in 5 test cases)

Build verified on Linux/GCC: cmake --build build --target BambuStudio -j$(nproc) completes without new warnings or errors.

Ref: #10289

@tinezivic tinezivic force-pushed the fix/ui-quickwins-idle-timer-cmake branch from f076918 to f72afbc Compare April 26, 2026 19:12
@tinezivic tinezivic changed the title FIX: remove ODR duplicate CMake sources, plug timer leak, debounce idle config save fix: remove duplicate CMake sources, plug timer leak, debounce idle config save Apr 26, 2026
@tinezivic tinezivic force-pushed the fix/ui-quickwins-idle-timer-cmake branch from f72afbc to 96c8260 Compare April 26, 2026 23:46
…onfig save

F-010: Scrollbar.cpp and ScrolledWindow.cpp were listed twice in
SLIC3R_GUI_SOURCES. Removed the redundant entries.

F-006: Sidebar::priv::~priv() never deleted timer_sync_printer (heap-allocated
via = new wxTimer()). Added Stop() + delete + null-out in the destructor.

F-015: idle handler called app_config->save() on every dirty idle event.
Added 5-second rate limit via debounce_elapsed() (Debounce.hpp, pure C++,
no wx dependency). OnExit() flushes remaining dirty state on clean shutdown.

Extracted debounce logic to src/libslic3r/Debounce.hpp with 5 Catch2 tests
(7 assertions, all passed). Build verified on Linux/GCC without new warnings.

Ref: bambulab#10289
@tinezivic tinezivic force-pushed the fix/ui-quickwins-idle-timer-cmake branch from 96c8260 to aba33e8 Compare April 27, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant