VcsBase: Fix memory leak

Change-Id: Icb0c2a86ee0d5a1e22dc17fbc2a5d155b928e459
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Christian Kandeler
2020-02-06 12:20:23 +01:00
parent 4454873b54
commit 67f66a39be
2 changed files with 4 additions and 8 deletions

View File

@@ -25,21 +25,17 @@
#include <QDesktopServices>
#include <QPlainTextEdit>
#include <QRegularExpression>
#include <QTextCursor>
#include <QUrl>
namespace VcsBase {
VcsOutputFormatter::VcsOutputFormatter()
{
m_urlRegexp = new QRegularExpression("https?://\\S*");
}
VcsOutputFormatter::VcsOutputFormatter() : m_urlRegexp("https?://\\S*") {}
void VcsOutputFormatter::appendMessage(const QString &text, Utils::OutputFormat format)
{
QString out = text;
const QRegularExpressionMatch match = m_urlRegexp->match(text);
const QRegularExpressionMatch match = m_urlRegexp.match(text);
if (match.hasMatch()) {
const QTextCharFormat normalFormat = charFormat(format);
OutputFormatter::appendMessage(text.left(match.capturedStart()), format);

View File

@@ -25,7 +25,7 @@
#include <utils/outputformatter.h>
QT_FORWARD_DECLARE_CLASS(QRegularExpression);
#include <QRegularExpression>
namespace VcsBase {
@@ -38,7 +38,7 @@ public:
void handleLink(const QString &href) override;
private:
QRegularExpression *m_urlRegexp = nullptr;
const QRegularExpression m_urlRegexp;
};
}