From e63ebdce91df465dcd44f4b4380fd49bd02bae2c Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 2 Aug 2014 12:38:55 -0700 Subject: [PATCH] Don't use "type" of source, use "id" of source The naming here is a poor choice, a source type determines if a source is either a regular input, a filter, or a transition. The ID is the actual unique identifier of a source. --- obs/window-basic-source-select.cpp | 26 +++++++++++++------------- obs/window-basic-source-select.hpp | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/obs/window-basic-source-select.cpp b/obs/window-basic-source-select.cpp index 76f97c3b9..29d44f0ba 100644 --- a/obs/window-basic-source-select.cpp +++ b/obs/window-basic-source-select.cpp @@ -25,11 +25,11 @@ bool OBSBasicSourceSelect::EnumSources(void *data, obs_source_t source) { OBSBasicSourceSelect *window = static_cast(data); const char *name = obs_source_getname(source); - const char *type; + const char *id; - obs_source_gettype(source, nullptr, &type); + obs_source_gettype(source, nullptr, &id); - if (strcmp(type, window->type) == 0) + if (strcmp(id, window->id) == 0) window->ui->sourceList->addItem(QT_UTF8(name)); return true; @@ -56,10 +56,10 @@ void OBSBasicSourceSelect::OBSSourceRemoved(void *data, calldata_t calldata) void OBSBasicSourceSelect::SourceAdded(OBSSource source) { const char *name = obs_source_getname(source); - const char *sourceType; + const char *sourceId; - obs_source_gettype(source, nullptr, &sourceType); - if (strcmp(sourceType, type) != 0) + obs_source_gettype(source, nullptr, &sourceId); + if (strcmp(sourceId, id) != 0) return; ui->sourceList->addItem(name); @@ -68,10 +68,10 @@ void OBSBasicSourceSelect::SourceAdded(OBSSource source) void OBSBasicSourceSelect::SourceRemoved(OBSSource source) { const char *name = obs_source_getname(source); - const char *sourceType; + const char *sourceId; - obs_source_gettype(source, nullptr, &sourceType); - if (strcmp(sourceType, type) != 0) + obs_source_gettype(source, nullptr, &sourceId); + if (strcmp(sourceId, id) != 0) return; QList items = @@ -149,7 +149,7 @@ void OBSBasicSourceSelect::on_buttonBox_accepted() return; } - if (!AddNew(this, type, QT_TO_UTF8(ui->sourceName->text()))) + if (!AddNew(this, id, QT_TO_UTF8(ui->sourceName->text()))) return; } @@ -161,15 +161,15 @@ void OBSBasicSourceSelect::on_buttonBox_rejected() done(DialogCode::Rejected); } -OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, const char *type_) +OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, const char *id_) : QDialog (parent), ui (new Ui::OBSBasicSourceSelect), - type (type_) + id (id_) { ui->setupUi(this); QString placeHolderText{QT_UTF8(obs_source_getdisplayname( - OBS_SOURCE_TYPE_INPUT, type_))}; + OBS_SOURCE_TYPE_INPUT, id))}; QString text{placeHolderText}; int i = 1; diff --git a/obs/window-basic-source-select.hpp b/obs/window-basic-source-select.hpp index 2df599c89..dbebf0cb3 100644 --- a/obs/window-basic-source-select.hpp +++ b/obs/window-basic-source-select.hpp @@ -29,7 +29,7 @@ class OBSBasicSourceSelect : public QDialog { private: std::unique_ptr ui; - const char *type; + const char *id; static bool EnumSources(void *data, obs_source_t source); @@ -44,5 +44,5 @@ private slots: void SourceRemoved(OBSSource source); public: - OBSBasicSourceSelect(OBSBasic *parent, const char *type); + OBSBasicSourceSelect(OBSBasic *parent, const char *id); }; -- GitLab