mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-15 08:15:06 +00:00
configuration: Don't leak pointers and add messages to exceptions
This commit is contained in:
parent
d4206f3a92
commit
aad7f64800
2 changed files with 10 additions and 8 deletions
|
@ -44,18 +44,18 @@ streamfx::configuration::~configuration()
|
|||
streamfx::configuration::configuration() : _data(), _config_path()
|
||||
{
|
||||
{ // Retrieve global configuration path.
|
||||
const char* path = obs_module_config_path("config.json");
|
||||
char* path = obs_module_config_path("config.json");
|
||||
_config_path = path;
|
||||
bfree(path);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!std::filesystem::exists(_config_path) || !std::filesystem::is_regular_file(_config_path)) {
|
||||
throw std::exception();
|
||||
throw std::runtime_error("Configuration does not exist.");
|
||||
} else {
|
||||
obs_data_t* data =
|
||||
obs_data_create_from_json_file_safe(_config_path.string().c_str(), path_backup_ext.data());
|
||||
obs_data_t* data = obs_data_create_from_json_file_safe(_config_path.string().c_str(), path_backup_ext.data());
|
||||
if (!data) {
|
||||
throw std::exception();
|
||||
throw std::runtime_error("Failed to load configuration from disk.");
|
||||
} else {
|
||||
_data = std::shared_ptr<obs_data_t>(data, obs::obs_data_deleter);
|
||||
}
|
||||
|
|
|
@ -59,13 +59,15 @@ inline void qt_cleanup_resource()
|
|||
|
||||
bool streamfx::ui::handler::have_shown_about_streamfx(bool shown)
|
||||
{
|
||||
auto config = streamfx::configuration::instance();
|
||||
auto data = config->get();
|
||||
if (shown) {
|
||||
obs_data_set_bool(streamfx::configuration::instance()->get().get(), _cfg_have_shown_about.data(), true);
|
||||
obs_data_set_bool(data.get(), _cfg_have_shown_about.data(), true);
|
||||
}
|
||||
if (streamfx::configuration::instance()->is_different_version()) {
|
||||
if (config->is_different_version()) {
|
||||
return false;
|
||||
} else {
|
||||
return obs_data_get_bool(streamfx::configuration::instance()->get().get(), _cfg_have_shown_about.data());
|
||||
return obs_data_get_bool(data.get(), _cfg_have_shown_about.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue