GSCapture: Fix invalid substring comparison

This commit is contained in:
Stenzek 2024-01-08 22:36:13 +10:00 committed by Connor McLaughlin
parent 6697e76be1
commit 14426a7b45
2 changed files with 5 additions and 3 deletions

View File

@ -1398,7 +1398,7 @@ std::optional<bool> QtHost::DownloadFile(QWidget* parent, const QString& title,
QtModalProgressCallback progress(parent);
progress.GetDialog().setLabelText(
qApp->translate("EmuThread", "Downloading %1...").arg(QtUtils::StringViewToQString(
std::string_view(url).substr((url_file_part_pos >= 0) ? (url_file_part_pos + 1) : 0))));
std::string_view(url).substr((url_file_part_pos != std::string::npos) ? (url_file_part_pos + 1) : 0))));
progress.GetDialog().setWindowTitle(title);
progress.GetDialog().setWindowIcon(GetAppIcon());
progress.SetCancellable(true);

View File

@ -25,11 +25,13 @@
#include <mutex>
#include <string>
// We're using deprecated fields because we're targeting multiple ffmpeg versions.
#if defined(_MSC_VER)
#pragma warning(disable:4996) // warning C4996: 'AVCodecContext::channels': was declared deprecated
#elif defined (__clang__)
// We're using deprecated fields because we're targeting multiple ffmpeg versions.
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined (__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
extern "C" {
@ -1359,7 +1361,7 @@ std::string GSCapture::GetNextCaptureFileName()
// Should end with a number.
int partnum = 2;
std::string_view::size_type pos = name.rfind("_part");
if (pos >= 0)
if (pos != std::string_view::npos)
{
std::string_view::size_type cpos = pos + 5;
for (; cpos < name.length(); cpos++)