diff options
author | Evgeniy A. Dushistov <dushistov@mail.ru> | 2021-04-13 14:13:14 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-04-14 15:46:12 +0000 |
commit | 5e023f3a9a8647f905c7dc4f1c73420dfa03b554 (patch) | |
tree | 1fcb1d0289a67bc7ed2a1e34747c14b8171217fc /tools | |
parent | 4543b0748200fe072446997b2d4394a00284ef75 (diff) |
qmlformat: fix QFSFileEngine::open: No file name specified
Since commit d48b87450327e710f7b0a843627624aa67cae116 qmlformat
prints the message:
QFSFileEngine::open: No file name specified
on normal usage like:
qmlformat path/to/qml
qmlformat -i path/to/qml
This is because it tries to open the file specific by the
"files" option event if no such option was passed.
Change-Id: Id14247210fc77a3f10dc25866607a9952fe81dfa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 45aa0853dae3f3068af08a6ed2d3248155e13e24)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlformat/main.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/qmlformat/main.cpp b/tools/qmlformat/main.cpp index da3c1772fb..3f11ce257a 100644 --- a/tools/qmlformat/main.cpp +++ b/tools/qmlformat/main.cpp @@ -224,17 +224,19 @@ Options buildCommandLineOptions(const QCoreApplication &app) } QStringList files; - QFile file(parser.value("files")); - file.open(QIODevice::Text | QIODevice::ReadOnly); - if (file.isOpen()) { - QTextStream in(&file); - while (!in.atEnd()) { - QString file = in.readLine(); - - if (file.isEmpty()) - continue; - - files.push_back(file); + if (parser.isSet("files")) { + QFile file(parser.value("files")); + file.open(QIODevice::Text | QIODevice::ReadOnly); + if (file.isOpen()) { + QTextStream in(&file); + while (!in.atEnd()) { + QString file = in.readLine(); + + if (file.isEmpty()) + continue; + + files.push_back(file); + } } } |