[libcalamaresui] No reason for bail() to be a method
This commit is contained in:
parent
526716556c
commit
bb2b5fd982
@ -41,6 +41,13 @@
|
|||||||
#include <KOSRelease>
|
#include <KOSRelease>
|
||||||
#endif
|
#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
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -153,7 +160,7 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
|
|||||||
QDir componentDir( componentDirectory() );
|
QDir componentDir( componentDirectory() );
|
||||||
if ( !componentDir.exists() )
|
if ( !componentDir.exists() )
|
||||||
{
|
{
|
||||||
bail( "Bad component directory path." );
|
bail( m_descriptorPath, "Bad component directory path." );
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file( brandingFilePath );
|
QFile file( brandingFilePath );
|
||||||
@ -168,7 +175,8 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
|
|||||||
|
|
||||||
m_componentName = QString::fromStdString( doc[ "componentName" ].as< std::string >() );
|
m_componentName = QString::fromStdString( doc[ "componentName" ].as< std::string >() );
|
||||||
if ( m_componentName != componentDir.dirName() )
|
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." );
|
"component directory." );
|
||||||
|
|
||||||
initSimpleSettings( doc );
|
initSimpleSettings( doc );
|
||||||
@ -214,7 +222,8 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
|
|||||||
// Not found, bail out with the filename used
|
// Not found, bail out with the filename used
|
||||||
if ( icon.isNull() )
|
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
|
return imageName; // Not turned into a path
|
||||||
}
|
}
|
||||||
@ -232,7 +241,8 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
|
|||||||
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
|
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
|
||||||
if ( !imageFi.exists() )
|
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();
|
slideShowPictures[ i ] = imageFi.absoluteFilePath();
|
||||||
@ -245,13 +255,14 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
|
|||||||
QString slideshowPath = QString::fromStdString( doc[ "slideshow" ].as< std::string >() );
|
QString slideshowPath = QString::fromStdString( doc[ "slideshow" ].as< std::string >() );
|
||||||
QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) );
|
QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) );
|
||||||
if ( !slideshowFi.exists() || !slideshowFi.fileName().toLower().endsWith( ".qml" ) )
|
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() ) );
|
.arg( slideshowFi.absoluteFilePath() ) );
|
||||||
m_slideshowPath = slideshowFi.absoluteFilePath();
|
m_slideshowPath = slideshowFi.absoluteFilePath();
|
||||||
}
|
}
|
||||||
else
|
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;
|
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 )
|
catch ( YAML::Exception& e )
|
||||||
{
|
{
|
||||||
CalamaresUtils::explainYamlException( e, ba, file.fileName() );
|
CalamaresUtils::explainYamlException( e, ba, file.fileName() );
|
||||||
bail( e.what() );
|
bail( m_descriptorPath, e.what() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir translationsDir( componentDir.filePath( "lang" ) );
|
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
|
} // namespace Calamares
|
||||||
|
@ -230,8 +230,6 @@ private:
|
|||||||
static const QStringList s_imageEntryStrings;
|
static const QStringList s_imageEntryStrings;
|
||||||
static const QStringList s_styleEntryStrings;
|
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_descriptorPath; // Path to descriptor (e.g. "/etc/calamares/default/branding.desc")
|
||||||
QString m_componentName; // Matches last part of full path to containing directory
|
QString m_componentName; // Matches last part of full path to containing directory
|
||||||
QMap< QString, QString > m_strings;
|
QMap< QString, QString > m_strings;
|
||||||
|
Loading…
Reference in New Issue
Block a user