UI: Fix crash when switching encoders in advanced mode

On linux, the JSON file handling code will try to read the directory
itself as a file, which can cause a crash.

Closes jp9000/obs-studio#681
This commit is contained in:
cryptonaut 2016-11-02 18:31:50 -07:00 committed by jp9000
parent 9982581a4f
commit 21ab517ba9

View File

@ -1290,14 +1290,16 @@ OBSPropertiesView *OBSBasicSettings::CreateEncoderPropertyView(
obs_data_t *settings = obs_encoder_defaults(encoder); obs_data_t *settings = obs_encoder_defaults(encoder);
OBSPropertiesView *view; OBSPropertiesView *view;
char encoderJsonPath[512]; if (path) {
int ret = GetProfilePath(encoderJsonPath, sizeof(encoderJsonPath), char encoderJsonPath[512];
path); int ret = GetProfilePath(encoderJsonPath,
if (ret > 0) { sizeof(encoderJsonPath), path);
obs_data_t *data = obs_data_create_from_json_file_safe( if (ret > 0) {
encoderJsonPath, "bak"); obs_data_t *data = obs_data_create_from_json_file_safe(
obs_data_apply(settings, data); encoderJsonPath, "bak");
obs_data_release(data); obs_data_apply(settings, data);
obs_data_release(data);
}
} }
view = new OBSPropertiesView(settings, encoder, view = new OBSPropertiesView(settings, encoder,