From 8e4a8b7e9d032df5953fa05324094769729e4110 Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 9 Jun 2020 07:10:30 -0400 Subject: [PATCH] Use QString::fromStdString() instead of c_str() --- src/executable-switch.cpp | 2 +- src/linux/advanced-scene-switcher-nix.cpp | 2 +- src/window-title-switch.cpp | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/executable-switch.cpp b/src/executable-switch.cpp index 7b345a35..05fef095 100644 --- a/src/executable-switch.cpp +++ b/src/executable-switch.cpp @@ -157,7 +157,7 @@ void SwitcherData::checkExeSwitch(bool &match, OBSWeakSource &scene, bool equals = (title == window); // True if ignored switch matches title bool matches = QString::fromStdString(title).contains( - QRegularExpression(window.c_str())); + QRegularExpression(QString::fromStdString(window))); if (equals || matches) { ignored = true; diff --git a/src/linux/advanced-scene-switcher-nix.cpp b/src/linux/advanced-scene-switcher-nix.cpp index 2fc9b261..8a134674 100644 --- a/src/linux/advanced-scene-switcher-nix.cpp +++ b/src/linux/advanced-scene-switcher-nix.cpp @@ -274,7 +274,7 @@ bool isFullscreen(std::string &title) bool equals = (title == name); // True if switch matches window bool matches = QString::fromStdString(name).contains( - QRegularExpression(title.c_str())); + QRegularExpression(QString::fromStdString(title))); // If found, check if switch is fullscreen if (equals || matches) { diff --git a/src/window-title-switch.cpp b/src/window-title-switch.cpp index 0e02a0f4..d31e6f80 100644 --- a/src/window-title-switch.cpp +++ b/src/window-title-switch.cpp @@ -7,10 +7,10 @@ bool isRunning(std::string &title) GetWindowList(windows); // True if switch is running (direct) - bool equals = windows.contains(title.c_str()); + bool equals = windows.contains(QString::fromStdString(title)); // True if switch is running (regex) - bool matches = - (windows.indexOf(QRegularExpression(title.c_str())) != -1); + bool matches = (windows.indexOf(QRegularExpression( + QString::fromStdString(title))) != -1); return (equals || matches); } @@ -24,7 +24,7 @@ bool isFocused(std::string &title) bool equals = (title == current); // True if switch matches current window bool matches = QString::fromStdString(current).contains( - QRegularExpression(title.c_str())); + QRegularExpression(QString::fromStdString(title))); return (equals || matches); } @@ -277,7 +277,7 @@ void SwitcherData::checkWindowTitleSwitch(bool &match, OBSWeakSource &scene, bool equals = (title == window); // True if ignored switch matches current window bool matches = QString::fromStdString(title).contains( - QRegularExpression(window.c_str())); + QRegularExpression(QString::fromStdString(window))); if (equals || matches) { ignored = true; @@ -295,9 +295,11 @@ void SwitcherData::checkWindowTitleSwitch(bool &match, OBSWeakSource &scene, // True if focus is disabled OR switch is focused bool focus = (!s.focus || isFocused(s.window)); // True if current window is ignored AND switch matches last window - bool ignore = (ignored && - QString::fromStdString(title).contains( - QRegularExpression(s.window.c_str()))); + bool ignore = + (ignored && + QString::fromStdString(title).contains( + QRegularExpression( + QString::fromStdString(s.window)))); if (isRunning(s.window) && (fullscreen && (focus || ignore))) { match = true;