obsproject / obs-websocket

Remote-control of OBS Studio through WebSocket
GNU General Public License v2.0
3.86k stars 707 forks source link

Bug: Config::Load returns early #1225

Closed opera-aberglund closed 4 months ago

opera-aberglund commented 4 months ago

Operating System Info

Other

Other OS

macOS 14.5

OBS Studio Version

Git

OBS Studio Version (Other)

No response

obs-websocket Version

Git

OBS Studio Log URL

https://obsproject.com/logs/DeqKETHOkSy1QS8C

OBS Studio Crash Log URL

No response

Expected Behavior

In Config::Load:

void Config::Load(json config)
{
    if (config.is_null()) {
        std::string configFilePath = Utils::Obs::StringHelper::GetModuleConfigPath(CONFIG_FILE_NAME);
        Utils::Json::GetJsonFileContent(configFilePath, config); // Fetch the existing config, which may not exist
    }

    // Should never happen, but just in case
    if (!config.is_object())
        return;
...

This function will exit early if the config.json file doesn't exist on the computer, for example if it was deleted. The expected behaviour would be that it created a new config file (with Config::Save?) in this case.

Current Behavior

The function exits early if config.json doesn't exist, because then config will not satisfy is_object, thus the config flags like ServerEnabled etc. are not written to.

Steps to Reproduce

  1. Delete config.json from app data on Windows or application support on mac
  2. Try to start OBS with a flag like --websocket_debug for instance (it won't trigger if Config::Load exits early)

Anything else we should know?

No response

tt2468 commented 4 months ago

Thanks for the bug report! I've just pushed a fix to resolve this.