Ensure names are valid

Ensure that a source has a valid name.  Duplicates aren't a big deal
internally, but sources without a name are probably something that
should be avoided.  Made is so that if a source is programmatically
created without a name, it's assigned an index based name.

In the main basic-mode window, made it check to make sure the name was
valid as well.
This commit is contained in:
jp9000
2014-03-10 13:39:51 -07:00
parent 35e7a2a9fe
commit 5288467aeb
5 changed files with 37 additions and 4 deletions

View File

@@ -586,6 +586,14 @@ void OBSBasic::on_actionAddScene_triggered()
name);
if (accepted) {
if (name.empty()) {
QMessageBox::information(this,
QTStr("MainWindow.NoNameEntered"),
QTStr("MainWindow.NoNameEntered"));
on_actionAddScene_triggered();
return;
}
obs_source_t source = obs_get_source_by_name(name.c_str());
if (source) {
QMessageBox::information(this,
@@ -661,9 +669,17 @@ void OBSBasic::AddSource(obs_scene_t scene, const char *id)
if (!accepted)
break;
if (name.empty()) {
QMessageBox::information(this,
QTStr("MainWindow.NoNameEntered"),
QTStr("MainWindow.NoNameEntered"));
continue;
}
obs_source_t source = obs_get_source_by_name(name.c_str());
if (!source) {
success = true;
break;
} else {
QMessageBox::information(this,
QTStr("MainWindow.NameExists.Title"),