mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 02:45:44 -05:00
[libcalamares] Complain if key isn't set
- Previous check would also fail when the setting is false, not just when the key is missing.
This commit is contained in:
parent
1a097f8c49
commit
b283ad69d5
1 changed files with 11 additions and 4 deletions
|
@ -29,13 +29,19 @@
|
|||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
static bool
|
||||
hasValue( const YAML::Node& v )
|
||||
{
|
||||
return !( ( v.Type() == YAML::NodeType::Null ) || ( v.Type() == YAML::NodeType::Undefined ) );
|
||||
}
|
||||
|
||||
/** Helper function to grab a QString out of the config, and to warn if not present. */
|
||||
static QString
|
||||
requireString( const YAML::Node& config, const char* key )
|
||||
{
|
||||
if ( config[ key ] )
|
||||
return QString::fromStdString( config[ key ].as< std::string >() );
|
||||
auto v = config[ key ];
|
||||
if ( hasValue(v) )
|
||||
return QString::fromStdString( v.as< std::string >() );
|
||||
else
|
||||
{
|
||||
cWarning() << "Required settings.conf key" << key << "is missing.";
|
||||
|
@ -47,8 +53,9 @@ requireString( const YAML::Node& config, const char* key )
|
|||
static bool
|
||||
requireBool( const YAML::Node& config, const char* key, bool d )
|
||||
{
|
||||
if ( config[ key ] )
|
||||
return config[ key ].as< bool >();
|
||||
auto v = config[ key ];
|
||||
if ( hasValue(v) )
|
||||
return v.as< bool >();
|
||||
else
|
||||
{
|
||||
cWarning() << "Required settings.conf key" << key << "is missing.";
|
||||
|
|
Loading…
Add table
Reference in a new issue