mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibCore+Everywhere: Return ErrorOr from ConfigFile::sync()
Currently this method always succeeds, but that won't be true once we switch to the Core::Stream API. :^) Some of these places would ideally show an error message to the user, since failure to save a file is significant, but let's not get distracted right now.
This commit is contained in:
parent
b90dc408bd
commit
cd0ffe5460
10 changed files with 39 additions and 24 deletions
|
@ -254,7 +254,7 @@ bool WindowManager::apply_workspace_settings(unsigned rows, unsigned columns, bo
|
|||
if (save) {
|
||||
m_config->write_num_entry("Workspace", "Rows", window_stack_rows());
|
||||
m_config->write_num_entry("Workspace", "Columns", window_stack_columns());
|
||||
return m_config->sync();
|
||||
return !m_config->sync().is_error();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -264,7 +264,8 @@ void WindowManager::set_acceleration_factor(double factor)
|
|||
ScreenInput::the().set_acceleration_factor(factor);
|
||||
dbgln("Saving acceleration factor {} to config file at {}", factor, m_config->filename());
|
||||
m_config->write_entry("Mouse", "AccelerationFactor", String::formatted("{}", factor));
|
||||
m_config->sync();
|
||||
if (auto result = m_config->sync(); result.is_error())
|
||||
dbgln("Failed to save config file: {}", result.error());
|
||||
}
|
||||
|
||||
void WindowManager::set_scroll_step_size(unsigned step_size)
|
||||
|
@ -272,7 +273,8 @@ void WindowManager::set_scroll_step_size(unsigned step_size)
|
|||
ScreenInput::the().set_scroll_step_size(step_size);
|
||||
dbgln("Saving scroll step size {} to config file at {}", step_size, m_config->filename());
|
||||
m_config->write_entry("Mouse", "ScrollStepSize", String::number(step_size));
|
||||
m_config->sync();
|
||||
if (auto result = m_config->sync(); result.is_error())
|
||||
dbgln("Failed to save config file: {}", result.error());
|
||||
}
|
||||
|
||||
void WindowManager::set_double_click_speed(int speed)
|
||||
|
@ -281,7 +283,8 @@ void WindowManager::set_double_click_speed(int speed)
|
|||
m_double_click_speed = speed;
|
||||
dbgln("Saving double-click speed {} to config file at {}", speed, m_config->filename());
|
||||
m_config->write_entry("Input", "DoubleClickSpeed", String::number(speed));
|
||||
m_config->sync();
|
||||
if (auto result = m_config->sync(); result.is_error())
|
||||
dbgln("Failed to save config file: {}", result.error());
|
||||
}
|
||||
|
||||
int WindowManager::double_click_speed() const
|
||||
|
@ -294,7 +297,8 @@ void WindowManager::set_buttons_switched(bool switched)
|
|||
m_buttons_switched = switched;
|
||||
dbgln("Saving mouse buttons switched state {} to config file at {}", switched, m_config->filename());
|
||||
m_config->write_bool_entry("Mouse", "ButtonsSwitched", switched);
|
||||
m_config->sync();
|
||||
if (auto result = m_config->sync(); result.is_error())
|
||||
dbgln("Failed to save config file: {}", result.error());
|
||||
}
|
||||
|
||||
bool WindowManager::get_buttons_switched() const
|
||||
|
@ -2080,7 +2084,10 @@ bool WindowManager::update_theme(String theme_path, String theme_name)
|
|||
m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(new_theme);
|
||||
m_config->write_entry("Theme", "Name", theme_name);
|
||||
m_config->remove_entry("Background", "Color");
|
||||
m_config->sync();
|
||||
if (auto result = m_config->sync(); result.is_error()) {
|
||||
dbgln("Failed to save config file: {}", result.error());
|
||||
return false;
|
||||
}
|
||||
invalidate_after_theme_or_font_change();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue