File Fix-version-check-for-GDB-10.x.patch of Package kdevelop5.15541
From 8831937ffe4849258ed282cb0c720fe1cf2705d4 Mon Sep 17 00:00:00 2001
From: Milian Wolff <mail@milianw.de>
Date: Mon, 26 Oct 2020 12:58:16 +0100
Subject: [PATCH] Fix version check for GDB 10.x
Don't try to parse a version via a regex, just QVersionNumber
instead. While at it, port to QRegularExpression and don't
crash if the response list is empty.
---
plugins/gdb/debugsession.cpp | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/plugins/gdb/debugsession.cpp b/plugins/gdb/debugsession.cpp
index 48a8ebbe95..f52360f17d 100644
--- a/plugins/gdb/debugsession.cpp
+++ b/plugins/gdb/debugsession.cpp
@@ -52,6 +52,8 @@
#include <QFileInfo>
#include <QStandardPaths>
#include <QGuiApplication>
+#include <QRegularExpression>
+#include <QVersionNumber>
using namespace KDevMI::GDB;
using namespace KDevMI::MI;
@@ -278,20 +280,20 @@ bool DebugSession::loadCoreFile(KDevelop::ILaunchConfiguration*,
void DebugSession::handleVersion(const QStringList& s)
{
- qCDebug(DEBUGGERGDB) << s.first();
+ const auto response = s.value(0);
+ qCDebug(DEBUGGERGDB) << response;
// minimal version is 7.0,0
- QRegExp rx(QStringLiteral("([7-9]+)\\.([0-9]+)(\\.([0-9]+))?"));
- int idx = rx.indexIn(s.first());
- if (idx == -1)
- {
+ QRegularExpression rx(QStringLiteral("([0-9]+)\\.([0-9]+)(\\.([0-9]+))?"));
+ const auto match = rx.match(response);
+ if (!match.hasMatch() || QVersionNumber::fromString(match.capturedRef(0)) < QVersionNumber(7, 0, 0)) {
if (!qobject_cast<QGuiApplication*>(qApp)) {
//for unittest
qFatal("You need a graphical application.");
}
- const QString messageText =
- i18n("<b>You need gdb 7.0.0 or higher.</b><br />"
- "You are using: %1", s.first());
+ const QString messageText = i18n("<b>You need gdb 7.0.0 or higher.</b><br />"
+ "You are using: %1",
+ response);
auto* message = new Sublime::Message(messageText, Sublime::Message::Error);
ICore::self()->uiController()->postMessage(message);
stopDebugger();
--
GitLab