OutputWindow: Do not activate links for empty reference

Change-Id: I1d4fc0f25f1882a34058c66c51376982cc70238e
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Orgad Shaneh
2020-06-18 07:52:26 +03:00
committed by Orgad Shaneh
parent c7b0940977
commit 6cfd240285
5 changed files with 66 additions and 58 deletions

View File

@@ -26,6 +26,8 @@
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <utils/qtcassert.h>
#include <QDesktopServices>
#include <QMenu>
#include <QPlainTextEdit>
@@ -64,9 +66,10 @@ Utils::OutputLineParser::Result VcsOutputLineParser::handleLine(const QString &t
bool VcsOutputLineParser::handleLink(const QString &href)
{
QTC_ASSERT(!href.isEmpty(), return false);
if (href.startsWith("http://") || href.startsWith("https://"))
QDesktopServices::openUrl(QUrl(href));
else if (!href.isEmpty())
else
emit referenceClicked(href);
return true;
}
@@ -74,7 +77,8 @@ bool VcsOutputLineParser::handleLink(const QString &href)
void VcsOutputLineParser::fillLinkContextMenu(
QMenu *menu, const QString &workingDirectory, const QString &href)
{
if (href.isEmpty() || href.startsWith("http://") || href.startsWith("https://")) {
QTC_ASSERT(!href.isEmpty(), return);
if (href.startsWith("http://") || href.startsWith("https://")) {
QAction *action = menu->addAction(
tr("&Open \"%1\"").arg(href),
[href] { QDesktopServices::openUrl(QUrl(href)); });