From bb2b5fd982bb831373370594996b29e092fdd486 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 7 May 2020 20:41:40 +0200 Subject: [PATCH] [libcalamaresui] No reason for bail() to be a method --- src/libcalamaresui/Branding.cpp | 33 ++++++++++++++++++--------------- src/libcalamaresui/Branding.h | 2 -- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 86aa04251..87cfda080 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -41,6 +41,13 @@ #include #endif +[[noreturn]] static void +bail( const QString& descriptorPath, const QString& message ) +{ + cError() << "FATAL in" << descriptorPath << Logger::Continuation << Logger::NoQuote {} << message; + ::exit( EXIT_FAILURE ); +} + namespace Calamares { @@ -153,7 +160,7 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) QDir componentDir( componentDirectory() ); if ( !componentDir.exists() ) { - bail( "Bad component directory path." ); + bail( m_descriptorPath, "Bad component directory path." ); } QFile file( brandingFilePath ); @@ -168,7 +175,8 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) m_componentName = QString::fromStdString( doc[ "componentName" ].as< std::string >() ); if ( m_componentName != componentDir.dirName() ) - bail( "The branding component name should match the name of the " + bail( m_descriptorPath, + "The branding component name should match the name of the " "component directory." ); initSimpleSettings( doc ); @@ -214,7 +222,8 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) // Not found, bail out with the filename used if ( icon.isNull() ) { - bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) ); + bail( m_descriptorPath, + QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) ); } return imageName; // Not turned into a path } @@ -232,7 +241,8 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) ); if ( !imageFi.exists() ) { - bail( QString( "Slideshow file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) ); + bail( m_descriptorPath, + QString( "Slideshow file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) ); } slideShowPictures[ i ] = imageFi.absoluteFilePath(); @@ -245,13 +255,14 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) QString slideshowPath = QString::fromStdString( doc[ "slideshow" ].as< std::string >() ); QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) ); if ( !slideshowFi.exists() || !slideshowFi.fileName().toLower().endsWith( ".qml" ) ) - bail( QString( "Slideshow file %1 does not exist or is not a valid QML file." ) + bail( m_descriptorPath, + QString( "Slideshow file %1 does not exist or is not a valid QML file." ) .arg( slideshowFi.absoluteFilePath() ) ); m_slideshowPath = slideshowFi.absoluteFilePath(); } else { - bail( "Syntax error in slideshow sequence." ); + bail( m_descriptorPath, "Syntax error in slideshow sequence." ); } int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as< int >() : -1; @@ -265,7 +276,7 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) catch ( YAML::Exception& e ) { CalamaresUtils::explainYamlException( e, ba, file.fileName() ); - bail( e.what() ); + bail( m_descriptorPath, e.what() ); } QDir translationsDir( componentDir.filePath( "lang" ) ); @@ -540,12 +551,4 @@ Branding::initSimpleSettings( const YAML::Node& doc ) } } - -[[noreturn]] void -Branding::bail( const QString& message ) -{ - cError() << "FATAL in" << m_descriptorPath << Logger::Continuation << Logger::NoQuote {} << message; - ::exit( EXIT_FAILURE ); -} - } // namespace Calamares diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 79e2542f1..87cb9fffa 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -230,8 +230,6 @@ private: static const QStringList s_imageEntryStrings; static const QStringList s_styleEntryStrings; - [[noreturn]] void bail( const QString& message ); - QString m_descriptorPath; // Path to descriptor (e.g. "/etc/calamares/default/branding.desc") QString m_componentName; // Matches last part of full path to containing directory QMap< QString, QString > m_strings;