mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-06-26 00:17:20 -04:00
When the app is quit on macOS, the underlying process is either triggered by an application-level "Quit" event or by a main window "close" event. If the application-level "Quit" event is the trigger, OBSBasic::saveAll is called twice: First by Qt's session manager (via OBSApp::commitData) and another time by the main window's close event handled by OBSBasic::closeWindow. However if the main window is closed first (and is the first to call "saveAll") the underlying OAuth data object is destroyed after the data has been saved. When the second "saveAll" call takes place, it encounters a "nullptr" for the auth object, which makes "Auth::Save" effectively remove any OAuth configuration from the settings file (undoing prior work). At the other end, if the application quits first, some dock windows might have been explicitly closed by Qt before the main window is closed and thus the second call to "saveAll" will overwrite valid browser dock state data with incomplete data (any dock that has been closed by Qt before will not be present in that data). Wrapping the code responsible for saving OAuth and browser dock state data in a "std::call_once" block should ensure that this data is only written once and by whoever gets to call "saveAll" first (at which point state data is still considered "complete").