From 93f55570c4800d78760ad76207d8410622efaa9c Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Mon, 1 Mar 2021 15:03:15 +0100 Subject: [PATCH 1/4] Remove unused definitions QT_CONFIGURE_CROSSBUILD is always '0', so it's not necessary to keep conditional compilation in QMakeLibraryInfo. Also the QT_CONFIGURE_SYSROOTIFY_PREFIX definition is never used in the project. Task-number: QTBUG-75870 Change-Id: I1fe42dce40fddc6a72254736883f93aa4727f6b3 Reviewed-by: Joerg Bornemann --- qmake/qmakelibraryinfo.cpp | 10 ++-------- src/corelib/global/qconfig.cpp.in | 4 ---- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp index 581d1ad0862..273da190d47 100644 --- a/qmake/qmakelibraryinfo.cpp +++ b/qmake/qmakelibraryinfo.cpp @@ -156,14 +156,8 @@ static QString getHostPrefixFromHostBinDir() return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH); } -static QString getPrefix(QMakeLibraryInfo::PathGroup group) +static QString getPrefix() { -#if QT_CONFIGURE_CROSSBUILD - if (group == QMakeLibraryInfo::DevicePaths) - return QString::fromLocal8Bit(QT_CONFIGURE_PREFIX_PATH); -#else - Q_UNUSED(group); -#endif return getExtPrefixFromHostBinDir(); } @@ -268,7 +262,7 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group // strlen is meaningless. const char *volatile path = nullptr; if (loc == QLibraryInfo::PrefixPath) { - ret = getPrefix(group); + ret = getPrefix(); } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets) / sizeof(qt_configure_str_offsets[0])) { path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; diff --git a/src/corelib/global/qconfig.cpp.in b/src/corelib/global/qconfig.cpp.in index d61b94c8061..ddfe1c65e1e 100644 --- a/src/corelib/global/qconfig.cpp.in +++ b/src/corelib/global/qconfig.cpp.in @@ -38,10 +38,6 @@ static const char qt_configure_strs[] = #define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "@QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH@" #define QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH@" #define QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH@" -#ifdef QT_BUILD_QMAKE -# define QT_CONFIGURE_CROSSBUILD 0 -# define QT_CONFIGURE_SYSROOTIFY_PREFIX false -#endif #define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12 #ifdef QT_BUILD_QMAKE # define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12 From d1101c460e173e3554fa4e5c800ab3e82ddc3aad Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Mon, 1 Mar 2021 15:31:42 +0100 Subject: [PATCH 2/4] Simplify prefix-related functionality of qmake Since the QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH and QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH definitions keep the same value in modern CMake build, no need to have special handling in cases where these values are used in qmake. Also it will be useful to specify the relative path to the prefix directory from the directories different of 'bin' when use QMakeLibraryInfo. Task-number: QTBUG-75870 Change-Id: I5a777001eb334dcf05e22853a514d4257352d59b Reviewed-by: Joerg Bornemann --- cmake/QtQmakeHelpers.cmake | 9 --------- qmake/CMakeLists.txt | 9 +++++++++ qmake/qmakelibraryinfo.cpp | 21 +++------------------ src/corelib/global/qconfig.cpp.in | 2 -- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake index 8f3c026fd66..fcfee7c3018 100644 --- a/cmake/QtQmakeHelpers.cmake +++ b/cmake/QtQmakeHelpers.cmake @@ -83,15 +83,6 @@ function(qt_generate_qconfig_cpp in_file out_file) "${lib_location_absolute_path}" "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") set(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "${from_lib_location_to_prefix}") - # The QT_CONFIGURE_HOSTBINDIR_TO_*PREFIX_PATH defines are exclusively used by qmake to determine - # the prefix from the location of the qmake executable. In our build of qmake host_prefix is - # always the same as ext_prefix, and we can just use CMAKE_INSTALL_PREFIX for the calculation of - # the relative path between /bin and . - set(bin_dir_absolute_path "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}") - file(RELATIVE_PATH from_bin_dir_to_prefix "${bin_dir_absolute_path}" "${CMAKE_INSTALL_PREFIX}") - set(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_bin_dir_to_prefix}") - set(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_bin_dir_to_prefix}") - configure_file(${in_file} ${out_file} @ONLY) endfunction() diff --git a/qmake/CMakeLists.txt b/qmake/CMakeLists.txt index 08b23df5875..5a464ece40f 100644 --- a/qmake/CMakeLists.txt +++ b/qmake/CMakeLists.txt @@ -21,6 +21,14 @@ Required features: return() endif() +# The QT_CONFIGURE_HOSTBINDIR_TO_*PREFIX_PATH defines are exclusively used by qmake to determine +# the prefix from the location of the qmake executable. In our build of qmake host_prefix is +# always the same as ext_prefix, and we can just use CMAKE_INSTALL_PREFIX for the calculation of +# the relative path between /bin and . +file(RELATIVE_PATH QT_CONFIGURE_RELATIVE_PREFIX_PATH + "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}" "${CMAKE_INSTALL_PREFIX}" +) + qt_get_tool_target_name(target_name qmake) qt_internal_add_tool(${target_name} TOOLS_TARGET Core # special case @@ -65,6 +73,7 @@ qt_internal_add_tool(${target_name} QT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} # special case QT_VERSION_MINOR=${PROJECT_VERSION_MINOR} # special case QT_VERSION_PATCH=${PROJECT_VERSION_PATCH} # special case + QT_CONFIGURE_RELATIVE_PREFIX_PATH="${QT_CONFIGURE_RELATIVE_PREFIX_PATH}" INCLUDE_DIRECTORIES generators generators/mac diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp index 273da190d47..ac8d1912485 100644 --- a/qmake/qmakelibraryinfo.cpp +++ b/qmake/qmakelibraryinfo.cpp @@ -139,26 +139,11 @@ void QMakeLibraryInfo::sysrootify(QString &path) } } -static QString getPrefixFromHostBinDir(const char *hostBinDirToPrefixPath) +static QString getPrefix() { const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath(); return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/') - + QLatin1String(hostBinDirToPrefixPath)); -} - -static QString getExtPrefixFromHostBinDir() -{ - return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH); -} - -static QString getHostPrefixFromHostBinDir() -{ - return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH); -} - -static QString getPrefix() -{ - return getExtPrefixFromHostBinDir(); + + QLatin1String(QT_CONFIGURE_RELATIVE_PREFIX_PATH)); } QString QMakeLibraryInfo::path(int loc) @@ -271,7 +256,7 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group path = QT_CONFIGURE_SETTINGS_PATH; #endif } else if (loc == HostPrefixPath) { - static const QByteArray hostPrefixPath = getHostPrefixFromHostBinDir().toLatin1(); + static const QByteArray hostPrefixPath = getPrefix().toLatin1(); path = hostPrefixPath.constData(); } diff --git a/src/corelib/global/qconfig.cpp.in b/src/corelib/global/qconfig.cpp.in index ddfe1c65e1e..57a5b4116ea 100644 --- a/src/corelib/global/qconfig.cpp.in +++ b/src/corelib/global/qconfig.cpp.in @@ -36,8 +36,6 @@ static const char qt_configure_strs[] = ; #define QT_CONFIGURE_SETTINGS_PATH "@QT_SYS_CONF_DIR@" #define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "@QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH@" -#define QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH@" -#define QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH@" #define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12 #ifdef QT_BUILD_QMAKE # define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12 From 5dab1e931d20f87fb35812fb64f6a2e344290cfa Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 26 Feb 2021 17:01:51 +0100 Subject: [PATCH 3/4] Improve QMakeLibraryInfo encapsulation QMakeLibraryInfo uses external data to produce paths. This causes issues when trying to use it out of the existing qmake environment. Add data fields that contain the path to the binary that uses QMakeLibraryInfo and manually specified qtconf. Task-number: QTBUG-75870 Change-Id: Ic6fa274ede3a9287826ff66c79f155b10d0d455c Reviewed-by: Joerg Bornemann --- qmake/library/ioutils.cpp | 34 +++++++++++++++++++++ qmake/library/ioutils.h | 1 + qmake/option.cpp | 62 +++++--------------------------------- qmake/qmakelibraryinfo.cpp | 29 +++++++++++++----- qmake/qmakelibraryinfo.h | 7 +++++ 5 files changed, 72 insertions(+), 61 deletions(-) diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp index 3a93298ffa1..719d3b514ac 100644 --- a/qmake/library/ioutils.cpp +++ b/qmake/library/ioutils.cpp @@ -49,6 +49,40 @@ QT_BEGIN_NAMESPACE using namespace QMakeInternal; +QString IoUtils::binaryAbsLocation(const QString &argv0) +{ + QString ret; + if (!argv0.isEmpty() && isAbsolutePath(argv0)) { + ret = argv0; + } else if (argv0.contains(QLatin1Char('/')) +#ifdef Q_OS_WIN + || argv0.contains(QLatin1Char('\\')) +#endif + ) { // relative PWD + ret = QDir::current().absoluteFilePath(argv0); + } else { // in the PATH + QByteArray pEnv = qgetenv("PATH"); + QDir currentDir = QDir::current(); +#ifdef Q_OS_WIN + QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(";")); + paths.prepend(QLatin1String(".")); +#else + QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(":")); +#endif + for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { + if ((*p).isEmpty()) + continue; + QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0); + if (QFile::exists(candidate)) { + ret = candidate; + break; + } + } + } + + return QDir::cleanPath(ret); +} + IoUtils::FileType IoUtils::fileType(const QString &fileName) { Q_ASSERT(fileName.isEmpty() || isAbsolutePath(fileName)); diff --git a/qmake/library/ioutils.h b/qmake/library/ioutils.h index f4555e8eeb1..c2b85dba04b 100644 --- a/qmake/library/ioutils.h +++ b/qmake/library/ioutils.h @@ -49,6 +49,7 @@ class QMAKE_EXPORT IoUtils { FileIsDir = 2 }; + static QString binaryAbsLocation(const QString &argv0); static FileType fileType(const QString &fileName); static bool exists(const QString &fileName) { return fileType(fileName) != FileNotFound; } static bool isRelativePath(const QString &fileName); diff --git a/qmake/option.cpp b/qmake/option.cpp index 09d790c9c23..1f9d60d7a80 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -202,8 +202,10 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state) continue; default: QMakeGlobals::ArgumentReturn cmdRet = globals->addCommandLineArguments(state, args, &x); - if (cmdRet == QMakeGlobals::ArgumentsOk) + if (cmdRet == QMakeGlobals::ArgumentsOk) { + QMakeLibraryInfo::qtconfManualPath = globals->qtconf; break; + } if (cmdRet == QMakeGlobals::ArgumentMalformed) { fprintf(stderr, "***Option %s requires a parameter\n", qPrintable(args.at(x - 1))); return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; @@ -326,46 +328,19 @@ Option::init(int argc, char **argv) #endif if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) Option::qmake_mode = default_mode(argv0); - if (!argv0.isEmpty() && IoUtils::isAbsolutePath(argv0)) { - globals->qmake_abslocation = argv0; - } else if (argv0.contains(QLatin1Char('/')) -#ifdef Q_OS_WIN - || argv0.contains(QLatin1Char('\\')) -#endif - ) { //relative PWD - globals->qmake_abslocation = QDir::current().absoluteFilePath(argv0); - } else { //in the PATH - QByteArray pEnv = qgetenv("PATH"); - QDir currentDir = QDir::current(); -#ifdef Q_OS_WIN - QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(";")); - paths.prepend(QLatin1String(".")); -#else - QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(":")); -#endif - for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { - if ((*p).isEmpty()) - continue; - QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0); - if (QFile::exists(candidate)) { - globals->qmake_abslocation = candidate; - break; - } - } - } + globals->qmake_abslocation = IoUtils::binaryAbsLocation(argv0); if (Q_UNLIKELY(globals->qmake_abslocation.isNull())) { // This is rather unlikely to ever happen on a modern system ... globals->qmake_abslocation = QMakeLibraryInfo::rawLocation(QMakeLibraryInfo::HostBinariesPath, QMakeLibraryInfo::EffectivePaths) + + "/qmake" #ifdef Q_OS_WIN - + "/qmake.exe"; -#else - + "/qmake"; + ".exe" #endif - } else { - globals->qmake_abslocation = QDir::cleanPath(globals->qmake_abslocation); + ; } + QMakeLibraryInfo::binaryAbsLocation = globals->qmake_abslocation; } else { Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; } @@ -656,25 +631,4 @@ qmakeAddCacheClear(qmakeCacheClearFunc func, void **data) cache_items.append(new QMakeCacheClearItem(func, data)); } -QString qmake_libraryInfoFile() -{ - if (!Option::globals->qtconf.isEmpty()) - return Option::globals->qtconf; - if (!Option::globals->qmake_abslocation.isEmpty()) { - QDir dir(QFileInfo(Option::globals->qmake_abslocation).absolutePath()); - QString qtconfig = dir.filePath("qt" QT_STRINGIFY(QT_VERSION_MAJOR) ".conf"); - if (QFile::exists(qtconfig)) - return qtconfig; - qtconfig = dir.filePath("qt.conf"); - if (QFile::exists(qtconfig)) - return qtconfig; - } - return QString(); -} - -QString qmake_abslocation() -{ - return Option::globals->qmake_abslocation; -} - QT_END_NAMESPACE diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp index ac8d1912485..e8bb70071ed 100644 --- a/qmake/qmakelibraryinfo.cpp +++ b/qmake/qmakelibraryinfo.cpp @@ -51,9 +51,8 @@ QT_BEGIN_NAMESPACE -// qmake_libraryInfoFile and qmake_abslocation are defined in option.cpp -QString qmake_libraryInfoFile(); -QString qmake_abslocation(); +QString QMakeLibraryInfo::binaryAbsLocation; +QString QMakeLibraryInfo::qtconfManualPath; struct QMakeLibrarySettings { @@ -72,7 +71,7 @@ Q_GLOBAL_STATIC(QMakeLibrarySettings, qmake_library_settings) QSettings *QMakeLibraryInfo::findConfiguration() { - QString qtconfig = qmake_libraryInfoFile(); + QString qtconfig = libraryInfoFile(); if (!qtconfig.isEmpty()) return new QSettings(qtconfig, QSettings::IniFormat); return nullptr; // no luck @@ -139,9 +138,9 @@ void QMakeLibraryInfo::sysrootify(QString &path) } } -static QString getPrefix() +QString QMakeLibraryInfo::getPrefix() { - const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath(); + const QString canonicalQMakePath = QFileInfo(binaryAbsLocation).canonicalPath(); return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/') + QLatin1String(QT_CONFIGURE_RELATIVE_PREFIX_PATH)); } @@ -274,7 +273,7 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group // We make the prefix/sysroot path absolute to the executable's directory. // loc == PrefixPath while a sysroot is set would make no sense here. // loc == SysrootPath only makes sense if qmake lives inside the sysroot itself. - baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); + baseDir = QFileInfo(libraryInfoFile()).absolutePath(); } else if (loc > SysrootPath && loc <= LastHostPath) { // We make any other host path absolute to the host prefix directory. baseDir = rawLocation(HostPrefixPath, group); @@ -289,4 +288,20 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group return ret; } +QString QMakeLibraryInfo::libraryInfoFile() +{ + if (!qtconfManualPath.isEmpty()) + return qtconfManualPath; + if (!binaryAbsLocation.isEmpty()) { + QDir dir(QFileInfo(binaryAbsLocation).absolutePath()); + QString qtconfig = dir.filePath("qt" QT_STRINGIFY(QT_VERSION_MAJOR) ".conf"); + if (QFile::exists(qtconfig)) + return qtconfig; + qtconfig = dir.filePath("qt.conf"); + if (QFile::exists(qtconfig)) + return qtconfig; + } + return QString(); +} + QT_END_NAMESPACE diff --git a/qmake/qmakelibraryinfo.h b/qmake/qmakelibraryinfo.h index 69b62e98768..a1983951277 100644 --- a/qmake/qmakelibraryinfo.h +++ b/qmake/qmakelibraryinfo.h @@ -75,6 +75,13 @@ struct QMakeLibraryInfo static void reload(); static bool haveGroup(PathGroup group); static void sysrootify(QString &path); + + static QString binaryAbsLocation; + static QString qtconfManualPath; + +private: + static QString getPrefix(); + static QString libraryInfoFile(); }; QT_END_NAMESPACE From fe1ef3ebcbfe017bdb01e16480a5c38cad6e39b9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Feb 2021 07:55:28 +0100 Subject: [PATCH 4/4] Brush up the imageviewer example - Fix the save as file dialog being in "Open" mode by setting acceptMode - Fix clazy warnings about detaching QList by using constFirst() - Fix clazy warning about passing a context to slot connection Pick-to: 6.0 6.1 5.15 Change-Id: I0c800e9829e118fcec477322aa2a13660e3b51d2 Reviewed-by: Eirik Aavitsland --- examples/widgets/widgets/imageviewer/imageviewer.cpp | 7 ++++--- examples/widgets/widgets/imageviewer/main.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index 7de0c7c45bb..bce74a24343 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -176,6 +176,7 @@ static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMo mimeTypeFilters.sort(); dialog.setMimeTypeFilters(mimeTypeFilters); dialog.selectMimeTypeFilter("image/jpeg"); + dialog.setAcceptMode(acceptMode); if (acceptMode == QFileDialog::AcceptSave) dialog.setDefaultSuffix("jpg"); } @@ -185,7 +186,7 @@ void ImageViewer::open() QFileDialog dialog(this, tr("Open File")); initializeImageFileDialog(dialog, QFileDialog::AcceptOpen); - while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().first())) {} + while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().constFirst())) {} } //! [1] @@ -194,7 +195,7 @@ void ImageViewer::saveAs() QFileDialog dialog(this, tr("Save File As")); initializeImageFileDialog(dialog, QFileDialog::AcceptSave); - while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().first())) {} + while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().constFirst())) {} } //! [5] @@ -365,7 +366,7 @@ void ImageViewer::createActions() QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(tr("&About"), this, &ImageViewer::about); - helpMenu->addAction(tr("About &Qt"), &QApplication::aboutQt); + helpMenu->addAction(tr("About &Qt"), this, &QApplication::aboutQt); } //! [18] diff --git a/examples/widgets/widgets/imageviewer/main.cpp b/examples/widgets/widgets/imageviewer/main.cpp index 035c7696930..fbfaecde459 100644 --- a/examples/widgets/widgets/imageviewer/main.cpp +++ b/examples/widgets/widgets/imageviewer/main.cpp @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) commandLineParser.process(QCoreApplication::arguments()); ImageViewer imageViewer; if (!commandLineParser.positionalArguments().isEmpty() - && !imageViewer.loadFile(commandLineParser.positionalArguments().front())) { + && !imageViewer.loadFile(commandLineParser.positionalArguments().constFirst())) { return -1; } imageViewer.show();