make sure another source by the same name doesn't already exist when choosing a name for that scene

This commit is contained in:
jp9000 2013-12-29 09:17:00 -07:00
parent c4af3e2a75
commit 6fe59f77ec
4 changed files with 19 additions and 2 deletions

View File

@ -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"

View File

@ -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;
}
}

View File

@ -17,6 +17,8 @@
#include <obs.hpp>
#include <wx/msgdlg.h>
#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);

View File

@ -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);
}