ptz-controls: auto-save config + clamp preset_max - #323
Conversation
|
Have you run tested this PR? |
Sorry for the slow reply. Yes — run tested with OBS Studio 32.2.1 against a VISCA-over-IP camera. The case I cared about is the one the PR is for: change presets, wait for the auto-save interval, then kill the OBS process instead of quitting cleanly. With this patch the presets are still there after restarting OBS; on Two things I have not covered and would like a second opinion on:
One more thing: this branch has never had a CI run — the Checks tab is empty because the workflow was never approved for the fork. I am rebasing onto current |
The plugin only writes its configuration on a clean shutdown, when the OBS_FRONTEND_EVENT_EXIT event fires. If OBS crashes or is killed, any changes made during the session - new presets, renamed devices, joystick and live-move settings - are lost. Add a 30 second auto-save timer that calls SaveConfig() whenever the configuration has been modified. To avoid scattering dirty-tracking calls throughout every setter, the dirty flag is raised from a single slot, markConfigDirty(), wired up centrally in the constructor to the existing change signals (PTZDevice::settingsChanged and the autoselect / live-move / speed-ramp toggles). The timer only touches the disk when something actually changed, and loading the configuration at startup is explicitly excluded from marking it dirty. Signed-off-by: Eddy Weiz <eddyweiz@gmail.com>
The preset limit is read straight from the configuration and cast to size_t before being handed to PTZPresetModel. A corrupt or hand-edited config could hold a negative or absurdly large value, which after the cast to size_t would result in a huge preset count. Clamp the value to the same 1..128 range that the properties slider already enforces. Signed-off-by: Eddy Weiz <eddyweiz@gmail.com>
337db93 to
d69045a
Compare
Reworked from #302 per your review.
Both commits are clang-format clean and carry a DCO Signed-off-by line. The crash/threading change is intentionally left out since you reverted that approach, and the custom config backup is dropped as redundant with the existing obs_data_*_safe("bak") mechanism.