If an imported scene collection has a name that already exists, it will
instead be given a name plus an increment (e.g. "name 2", or "name 3",
etc)
Fixesobsproject/obs-studio#4442
GetUnusedSceneCollectionFile tries to create a safe, unused filename for
a new scene collection JSON file based on the user-specified scene
collection name. It would check the length of the safe version of the
user-specified name, but then it doesn't consider that the length may
have changed when GetClosestUnusedFileName was called to alter the
filename to prevent filename collisions by adding an incremented integer
to the end of the filename. This could result in OBS thinking a filename
was safe and available, but the resulting filename could be one that
already exists. OBS could then overwrite a scene collection JSON file
with this new file without any indication that the file previously
existed.
Instead of trying to calculate a length based off of the returned
filename, let's just use the length of the config path since it's a
known string.
This replaces the previous Open File dialog for importing collections
with a window for importing many collections at once, based on the remux
window, along with support for importing from OBS Classic, XSplit
Broadcaster and from Streamlabs' fork. This also translates sources
between OSes that Studio supports.
In the current user interface code, OBSBasic::AddSceneCollection has a
qname parameter to allow explicitly specifying a name, but that code
path is unused in the UI code itself, and qname is typically empty. If
qname is not empty, it does not properly generate a file name associated
with that specified scene collection name. This fixes that issue.
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed. Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
Allows the ability to add a new scene collection via the frontend API.
Blocks until the scene collection has been successfully added to ensure
synchronization between the calling thread and the UI thread.
(Jim: Added detailed description to commit message)
Closesobsproject/obs-studio#1232
Due to the commit 34c14829b6176248970bb, source loading is now deferred
to after OBSInit(), which would cause saved scene/source projectors to
no longer load on startup. This fixes that issue by moving the
OpenSavedProjectors call to OBSBasic::Load().
This code was originally tested with visual C, which supports using
__FUNCTION__ in this way. These potential error cases shouldn't
technically happen anyway, so just remove __FUNCTION__.
OBS assumes the name of the imported json file is also the name
of the scene collection, if the filename is different this can result
in duplicate scene collections after importing.
Closesjp9000/obs-studio#1177
When running the program for the first time, no scene collections will
show up in the scene collection menu. This changes it to forcibly save
the first scene collection on the first run of the program, and then
re-enumerates the list to ensure it's listed.
This commit fixes a bug that would cause the frontend API function
obs_frontend_set_current_scene_collection to never be successful. Due
to the bug, the following null pointer check would always fail, so the
action would never be triggered.
Modification by Jim: Instead of fixing the typo that caused this to
occur, make it so both scene collection menus and profile menus both use
"file_name" consistently.
Closesjp9000/obs-studio#712