UI: Miscellaneous code cleanups

Remove a few unused variables and other minor changes. No functional
differences. Issues detected by PVS Studio.
master
Richard Stanway 2020-09-27 18:14:47 +02:00
parent 1a14304784
commit 7d3fa7315a
7 changed files with 30 additions and 41 deletions

View File

@ -441,7 +441,6 @@ std::shared_ptr<Auth> TwitchAuth::Login(QWidget *parent)
return nullptr; return nullptr;
} }
std::string error;
if (auth->GetChannelInfo()) { if (auth->GetChannelInfo()) {
return auth; return auth;
} }

View File

@ -258,8 +258,6 @@ static Json::object translate_source(const Json &in, const Json &sources)
string winClass = in_settings["windowClass"].string_value(); string winClass = in_settings["windowClass"].string_value();
string exec = in_settings["executable"].string_value(); string exec = in_settings["executable"].string_value();
string window = ":" + winClass + ":" + exec;
settings["window"] = ":" + winClass + ":" + exec; settings["window"] = ":" + winClass + ":" + exec;
translate_bool("captureMouse", in_settings, "capture_cursor", translate_bool("captureMouse", in_settings, "capture_cursor",
@ -298,10 +296,9 @@ static void translate_sc(const Json &in, Json &out)
for (size_t i = 0; i < scenes.size(); i++) { for (size_t i = 0; i < scenes.size(); i++) {
Json in_scene = scenes[i]; Json in_scene = scenes[i];
if (first_name == "") if (first_name.empty())
first_name = in_scene["name"].string_value(); first_name = in_scene["name"].string_value();
Json::object settings = Json::object{};
Json::array items = Json::array{}; Json::array items = Json::array{};
Json::array sources = in_scene["sources"].array_items(); Json::array sources = in_scene["sources"].array_items();
@ -391,7 +388,7 @@ static void create_data_item(Json::object &out, const string &line)
Json::array new_arr = Json::array{}; Json::array new_arr = Json::array{};
string str = out[c_name].string_value(); string str = out[c_name].string_value();
create_string_obj(str, new_arr); create_string_obj(str, new_arr);
arr = new_arr; arr = std::move(new_arr);
} }
create_string_obj(first, arr); create_string_obj(first, arr);
@ -408,7 +405,7 @@ static void create_data_item(Json::object &out, const string &line)
Json::array new_arr = Json::array{}; Json::array new_arr = Json::array{};
string str1 = out[c_name].string_value(); string str1 = out[c_name].string_value();
create_string_obj(str1, new_arr); create_string_obj(str1, new_arr);
arr = new_arr; arr = std::move(new_arr);
} }
create_string_obj(str, arr); create_string_obj(str, arr);
@ -431,7 +428,7 @@ static Json::array create_sources(Json::object &out, string &line, string &src)
line = ReadLine(src); line = ReadLine(src);
size_t l_len = line.size(); size_t l_len = line.size();
while (line != "" && line[l_len - 1] != '}') { while (!line.empty() && line[l_len - 1] != '}') {
size_t end_pos = line.find(':'); size_t end_pos = line.find(':');
if (end_pos == string::npos) if (end_pos == string::npos)
@ -478,7 +475,7 @@ static Json::object create_object(Json::object &out, string &line, string &src)
size_t l_len = line.size() - 1; size_t l_len = line.size() - 1;
while (line != "" && line[l_len] != '}') { while (!line.empty() && line[l_len] != '}') {
start_pos = 0; start_pos = 0;
while (line[start_pos] == ' ') while (line[start_pos] == ' ')
start_pos++; start_pos++;
@ -511,10 +508,8 @@ int ClassicImporter::ImportScenes(const string &path, string &name, Json &res)
if (!file_data) if (!file_data)
return IMPORTER_FILE_WONT_OPEN; return IMPORTER_FILE_WONT_OPEN;
string sc_name = GetFilenameFromPath(path); if (name.empty())
name = GetFilenameFromPath(path);
if (name == "")
name = sc_name;
Json::object data = Json::object{}; Json::object data = Json::object{};
data["name"] = name; data["name"] = name;
@ -522,7 +517,7 @@ int ClassicImporter::ImportScenes(const string &path, string &name, Json &res)
string file = file_data.Get(); string file = file_data.Get();
string line = ReadLine(file); string line = ReadLine(file);
while (line != "" && line[0] != '\0') { while (!line.empty() && line[0] != '\0') {
string key = line != "global sources : {" ? "scenes" string key = line != "global sources : {" ? "scenes"
: "globals"; : "globals";

View File

@ -318,7 +318,7 @@ static int attempt_import(const Json &root, const string &name, Json &res)
while (source_name_exists(out_sources, out_name)) while (source_name_exists(out_sources, out_name))
out_name = name + "(" + to_string(copy++) + ")"; out_name = name + "(" + to_string(copy++) + ")";
if (scene_name == "") if (scene_name.empty())
scene_name = out_name; scene_name = out_name;
string sl_id = scene["id"].string_value(); string sl_id = scene["id"].string_value();
@ -399,7 +399,7 @@ string SLImporter::Name(const string &path)
string c_name = c["name"].string_value(); string c_name = c["name"].string_value();
if (c_id == manifest_file) { if (c_id == manifest_file) {
name = c_name; name = std::move(c_name);
name_set = true; name_set = true;
break; break;
} }

View File

@ -233,7 +233,7 @@ static void parse_items(QDomNode &item, Json::array &items,
} }
name = attr.namedItem("cname").nodeValue().toStdString(); name = attr.namedItem("cname").nodeValue().toStdString();
if (name == "" || name[0] == '\0') if (name.empty() || name[0] == '\0')
name = attr.namedItem("name").nodeValue().toStdString(); name = attr.namedItem("name").nodeValue().toStdString();
temp_name = name; temp_name = name;
@ -264,7 +264,7 @@ static void parse_items(QDomNode &item, Json::array &items,
} else if (type == 2) { } else if (type == 2) {
QString audio = attr.namedItem("itemaudio").nodeValue(); QString audio = attr.namedItem("itemaudio").nodeValue();
if (audio == "") { if (audio.isEmpty()) {
source["id"] = "dshow_input"; source["id"] = "dshow_input";
} else { } else {
source["id"] = "wasapi_input_capture"; source["id"] = "wasapi_input_capture";
@ -294,7 +294,7 @@ static void parse_items(QDomNode &item, Json::array &items,
QString display = QString display =
o_attr.namedItem("desktop").nodeValue(); o_attr.namedItem("desktop").nodeValue();
if (display != "") { if (!display.isEmpty()) {
source["id"] = "monitor_capture"; source["id"] = "monitor_capture";
int cursor = attr.namedItem("ScrCapShowMouse") int cursor = attr.namedItem("ScrCapShowMouse")
.nodeValue() .nodeValue()
@ -312,7 +312,7 @@ static void parse_items(QDomNode &item, Json::array &items,
int pos = exec.lastIndexOf('\\'); int pos = exec.lastIndexOf('\\');
if (_class == "") { if (_class.isEmpty()) {
_class = "class"; _class = "class";
} }
@ -421,7 +421,7 @@ static Json::object parse_scenes(QDomElement &scenes)
QString name = attr.namedItem("name").nodeValue(); QString name = attr.namedItem("name").nodeValue();
QString id = attr.namedItem("id").nodeValue(); QString id = attr.namedItem("id").nodeValue();
if (first == "") if (first.isEmpty())
first = name; first = name;
Json out = Json::object{ Json out = Json::object{
@ -492,7 +492,7 @@ bool XSplitImporter::Check(const string &path)
string pos = file_data.Get(); string pos = file_data.Get();
string line = ReadLine(pos); string line = ReadLine(pos);
while (line != "") { while (!line.empty()) {
if (line.substr(0, 5) == "<?xml") { if (line.substr(0, 5) == "<?xml") {
line = ReadLine(pos); line = ReadLine(pos);
} else { } else {

View File

@ -458,8 +458,8 @@ void AutoConfigTestPage::TestBandwidthThread()
} }
} }
wiz->server = bestServer; wiz->server = std::move(bestServer);
wiz->serverName = bestServerName; wiz->serverName = std::move(bestServerName);
wiz->idealBitrate = bestBitrate; wiz->idealBitrate = bestBitrate;
QMetaObject::invokeMethod(this, "NextStage"); QMetaObject::invokeMethod(this, "NextStage");

View File

@ -1939,14 +1939,11 @@ void OBSBasic::OnFirstLoad()
/* Attempt to load init screen if available */ /* Attempt to load init screen if available */
if (cef) { if (cef) {
WhatsNewInfoThread *wnit = new WhatsNewInfoThread(); WhatsNewInfoThread *wnit = new WhatsNewInfoThread();
if (wnit) { connect(wnit, &WhatsNewInfoThread::Result, this,
connect(wnit, &WhatsNewInfoThread::Result, this,
&OBSBasic::ReceivedIntroJson); &OBSBasic::ReceivedIntroJson);
}
if (wnit) { introCheckThread.reset(wnit);
introCheckThread.reset(wnit); introCheckThread->start();
introCheckThread->start();
}
} }
#endif #endif
@ -2061,14 +2058,13 @@ void OBSBasic::ReceivedIntroJson(const QString &text)
WhatsNewBrowserInitThread *wnbit = WhatsNewBrowserInitThread *wnbit =
new WhatsNewBrowserInitThread(QT_UTF8(info_url.c_str())); new WhatsNewBrowserInitThread(QT_UTF8(info_url.c_str()));
if (wnbit) {
connect(wnbit, &WhatsNewBrowserInitThread::Result, this, connect(wnbit, &WhatsNewBrowserInitThread::Result, this,
&OBSBasic::ShowWhatsNew); &OBSBasic::ShowWhatsNew);
}
if (wnbit) { whatsNewInitThread.reset(wnbit);
whatsNewInitThread.reset(wnbit); whatsNewInitThread->start();
whatsNewInitThread->start();
}
#else #else
UNUSED_PARAMETER(text); UNUSED_PARAMETER(text);
#endif #endif
@ -7051,8 +7047,7 @@ OBSProjector *OBSBasic::OpenProjector(obs_source_t *source, int monitor,
OBSProjector *projector = OBSProjector *projector =
new OBSProjector(nullptr, source, monitor, type); new OBSProjector(nullptr, source, monitor, type);
if (projector) projectors.emplace_back(projector);
projectors.emplace_back(projector);
return projector; return projector;
} }

View File

@ -283,7 +283,7 @@ void ImporterModel::checkInputPath(int row)
std::string program = DetectProgram(entry.path.toStdString()); std::string program = DetectProgram(entry.path.toStdString());
entry.program = QTStr(program.c_str()); entry.program = QTStr(program.c_str());
if (program == "") { if (program.empty()) {
entry.selected = false; entry.selected = false;
} else { } else {
std::string name = std::string name =