diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-07-19 12:12:05 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-07-30 11:26:58 +0200 |
commit | 42872e720b2d25501587b0ed95f183d2dd9c8441 (patch) | |
tree | aeb748eea1affd1a6cab460746e55b585332413f | |
parent | f1d213b4039e38bb9ceebaca9167fcb722a0c16e (diff) |
Fix debug output for QQmlError when url is a resource
It failed to show the content of the file that had an error if the file
was embedded as a resource.
Change-Id: Ib8e0627919fa1f7956588ac80179adb8539df0e3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/qml/qqmlerror.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmlerror/tst_qqmlerror.cpp | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp index 739d5ce4cd..0b94ed3b49 100644 --- a/src/qml/qml/qqmlerror.cpp +++ b/src/qml/qml/qqmlerror.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qqmlerror.h" +#include "qqmlfile.h" #include "qqmlsourcecoordinate_p.h" #include <private/qqmljsdiagnosticmessage_p.h> @@ -307,8 +308,8 @@ QDebug operator<<(QDebug debug, const QQmlError &error) QUrl url = error.url(); - if (error.line() > 0 && url.scheme() == QLatin1String("file")) { - QString file = url.toLocalFile(); + if (error.line() > 0 && (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("qrc"))) { + QString file = QQmlFile::urlToLocalFileOrQrc(url); QFile f(file); if (f.open(QIODevice::ReadOnly)) { QByteArray data = f.readAll(); diff --git a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp index 7a7185e909..f282e60417 100644 --- a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp +++ b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp @@ -195,7 +195,7 @@ void tst_qqmlerror::debug() } { - QUrl url(dataDirectoryUrl().resolved(QUrl("test.txt"))); + QUrl url = testFileUrl("test.txt"); QQmlError error; error.setUrl(url); error.setDescription("An Error"); |