Skip to content

ptz-controls: auto-save config + clamp preset_max#323

Open
EdueskaWeiz wants to merge 2 commits into
glikely:mainfrom
EdueskaWeiz:pr/autosave
Open

ptz-controls: auto-save config + clamp preset_max#323
EdueskaWeiz wants to merge 2 commits into
glikely:mainfrom
EdueskaWeiz:pr/autosave

Conversation

@EdueskaWeiz

Copy link
Copy Markdown

Reworked from #302 per your review.

  • ptz-controls: periodic auto-save. The dirty flag is now raised from a single central slot wired to the existing change signals, instead of scattering markDirty() through every setter. Rationale is in the commit message rather than a separate .md file.
  • ptz-device: clamp preset_max to the 1..128 slider range (your "Use clamp()?" suggestion), guarding against corrupt configs.

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.

Eddy Weiz added 2 commits June 26, 2026 16:46
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>
@glikely

glikely commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Have you run tested this PR?

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.

2 participants