Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 62 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,11 @@
unsafe {
debug!("Loading settings.");

let global_timer = get_global_timer(splits_path);
let global_timer = get_global_timer(
splits_path,
#[cfg(feature = "auto-splitting")]
&local_auto_splitter,
);
global_timer
.timer
.auto_save
Expand All @@ -506,11 +510,6 @@
let texture = gs_texture_create(width, height, GS_RGBA, 1, ptr::null_mut(), GS_DYNAMIC);
obs_leave_graphics();

#[cfg(feature = "auto-splitting")]
if let Some(local_auto_splitter) = &local_auto_splitter {
auto_splitter_load(&global_timer, local_auto_splitter.clone())
}

Self {
#[cfg(feature = "auto-splitting")]
local_auto_splitter,
Expand Down Expand Up @@ -1838,23 +1837,62 @@
match &widget.kind {
WidgetKind::Title { .. } => {}
WidgetKind::Bool { default_value } => {
let value = obs_data_get_bool(settings_obj, data_key.as_ptr());
if value != *default_value {
map.insert(key.clone(), Value::Bool(value));
let old_value = state
.auto_splitter_map
.get(&key)

Check warning on line 1842 in src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
.and_then(|v| v.to_bool())
.unwrap_or(*default_value);
let asr_value = map
.get(&key)

Check warning on line 1846 in src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
.and_then(|v| v.to_bool())
.unwrap_or(*default_value);
if asr_value != old_value {
obs_data_set_bool(settings_obj, data_key.as_ptr(), asr_value);
state
.auto_splitter_map
.insert(key.clone(), Value::Bool(asr_value));
} else {
map.remove(key);
let obs_value = obs_data_get_bool(settings_obj, data_key.as_ptr());
if obs_value != *default_value {
map.insert(key.clone(), Value::Bool(obs_value));
} else {
map.remove(key);
}
}
}
WidgetKind::Choice {
default_option_key, ..
} => {
if let Some(value) =
let old_value = state
.auto_splitter_map
.get(&key)

Check warning on line 1869 in src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
.and_then(|v| v.as_string())
.unwrap_or(default_option_key);
let asr_value = map
.get(&key)

Check warning on line 1873 in src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
.and_then(|v| v.as_string())
.unwrap_or(default_option_key);
if asr_value != old_value {
if let Ok(new_value) =
CString::from_vec_with_nul(format!("{}\0", asr_value).into())
{
obs_data_set_string(
settings_obj,
data_key.as_ptr(),
new_value.as_ptr(),
);
}
state
.auto_splitter_map
.insert(key.clone(), Value::String(asr_value.clone()));
} else if let Some(obs_value) =
CStr::from_ptr(obs_data_get_string(settings_obj, data_key.as_ptr()))
.to_str()
.ok()
.filter(|v| *v != &**default_option_key)
{
map.insert(key.clone(), Value::String(Arc::from(value)));
map.insert(key.clone(), Value::String(Arc::from(obs_value)));
} else {
map.remove(key);
}
Expand Down Expand Up @@ -1908,10 +1946,17 @@
}

fn handle_splits_path_change(state: &mut State, splits_path: PathBuf) {
state.global_timer = get_global_timer(splits_path);
state.global_timer = get_global_timer(
splits_path,
#[cfg(feature = "auto-splitting")]
&state.local_auto_splitter,
);
}

fn get_global_timer(splits_path: PathBuf) -> Arc<GlobalTimer> {
fn get_global_timer(
splits_path: PathBuf,
#[cfg(feature = "auto-splitting")] local_auto_splitter: &Option<PathBuf>,
) -> Arc<GlobalTimer> {
let mut timers = TIMERS.lock().unwrap();
timers.retain(|timer| timer.strong_count() > 0);
if let Some(timer) = timers.iter().find_map(|timer| {
Expand Down Expand Up @@ -1942,6 +1987,10 @@
#[cfg(feature = "auto-splitting")]
auto_splitter_is_enabled: AtomicBool::new(false),
});
#[cfg(feature = "auto-splitting")]
if let Some(local_auto_splitter) = local_auto_splitter {
auto_splitter_load(&global_timer, local_auto_splitter.clone());
}
timers.push(Arc::downgrade(&global_timer));
global_timer
}
Expand Down
Loading