diff --git a/build/data/obs-studio/locale/en.txt b/build/data/obs-studio/locale/en.txt index 7d09194c5..80070546e 100644 --- a/build/data/obs-studio/locale/en.txt +++ b/build/data/obs-studio/locale/en.txt @@ -12,6 +12,9 @@ MainMenu.FIle.Save="Save" MainWindow.AddSceneDlg.Title="Add Scene" MainWindow.AddSceneDlg.Text="Please enter the name of the scene" +MainWindow.NameExists.Title="Name already exists" +MainWindow.NameExists.Text="The name is already in use by another source." + MainWindow.Exit="Exit" MainWindow.Lock="Lock Preview" MainWindow.Preview="Enable Preview" diff --git a/libobs/obs.c b/libobs/obs.c index 43ac8687b..936c88e9f 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -498,6 +498,7 @@ obs_source_t obs_get_source_by_name(const char *name) struct obs_source *cur_source = data->sources.array[i]; if (strcmp(cur_source->name, name) == 0) { source = cur_source; + obs_source_addref(source); break; } } diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index ff396b4e1..ab506e897 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -17,6 +17,8 @@ #include +#include + #include "obs-app.hpp" #include "wx-wrappers.hpp" #include "window-basic-settings.hpp" @@ -62,8 +64,8 @@ void OBSBasic::SourceAdded(void *data, calldata_t params) void OBSBasic::SourceDestroyed(void *data, calldata_t params) { OBSBasic *window = (OBSBasic*)data; - obs_source_t source; + obs_source_t source; calldata_getptr(params, "source", (void**)&source); obs_source_type type; @@ -191,6 +193,17 @@ void OBSBasic::sceneAddClicked(wxCommandEvent &event) name); if (ret == wxID_OK) { + obs_source_t source = obs_get_source_by_name(name.c_str()); + if (source) { + wxMessageBox(WXStr("MainWindow.NameExists.Text"), + WXStr("MainWindow.NameExists.Title"), + wxOK|wxCENTRE, this); + + obs_source_release(source); + sceneAddClicked(event); + return; + } + obs_scene_t scene = obs_scene_create(name.c_str()); obs_add_source(obs_scene_getsource(scene)); obs_scene_release(scene); diff --git a/obs/wx-wrappers.cpp b/obs/wx-wrappers.cpp index 554833806..cd7448336 100644 --- a/obs/wx-wrappers.cpp +++ b/obs/wx-wrappers.cpp @@ -42,6 +42,6 @@ void OBSErrorBox(wxWindow *parent, const char *message, ...) vsnprintf(output, 4095, message, args); va_end(args); - wxMessageBox(message, "Error"); + wxMessageBox(message, "Error", wxOK|wxCENTRE, parent); blog(LOG_ERROR, "%s", output); }