@@ -4034,7 +4034,7 @@ inline void load(const YAML::Node & node, ViewingRulesRcPtr & vr)
40344034 catch (Exception & ex)
40354035 {
40364036 std::ostringstream os;
4037- os << " File rules: " << ex.what ();
4037+ os << " Viewing rules: " << ex.what ();
40384038 throwError (node, os.str ().c_str ());
40394039 }
40404040}
@@ -4658,13 +4658,15 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen
46584658 config->setWorkingDir (configrootdir.c_str ());
46594659 }
46604660
4661- auto defaultCS = config->getColorSpace (ROLE_DEFAULT );
46624661 if (!fileRulesFound)
46634662 {
46644663 if (config->getMajorVersion () >= 2 )
46654664 {
4666- if (!defaultCS )
4665+ if (!config-> hasRole ( ROLE_DEFAULT ) )
46674666 {
4667+ // Note that no validation of the default color space is done (e.g. to check that
4668+ // it exists in the config) in order to enable loading configs that are only
4669+ // partially complete. The caller may use config->validate() after, if desired.
46684670 throwError (node, " The config must contain either a Default file rule or "
46694671 " the 'default' role." );
46704672 }
@@ -4683,6 +4685,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen
46834685 else
46844686 {
46854687 // If default role is also defined.
4688+ auto defaultCS = config->getColorSpace (ROLE_DEFAULT );
46864689 if (defaultCS)
46874690 {
46884691 const auto defaultRule = fileRules->getNumEntries () - 1 ;
@@ -4815,18 +4818,11 @@ inline void save(YAML::Emitter & out, const Config & config)
48154818 const char * role = config.getRoleName (i);
48164819 if (role && *role)
48174820 {
4818- ConstColorSpaceRcPtr colorspace = config.getColorSpace (role);
4819- if (colorspace)
4820- {
4821- out << YAML ::Key << role;
4822- out << YAML ::Value << config.getColorSpace (role)->getName ();
4823- }
4824- else
4825- {
4826- std::ostringstream os;
4827- os << " Colorspace associated to the role '" << role << " ', does not exist." ;
4828- throw Exception (os.str ().c_str ());
4829- }
4821+ // Note that no validation of the name strings is done here (e.g. to check that
4822+ // they exist in the config) in order to enable serializing configs that are only
4823+ // partially complete. The caller may use config->validate() first, if desired.
4824+ out << YAML ::Key << role;
4825+ out << YAML ::Value << config.getRoleColorSpace (i);
48304826 }
48314827 }
48324828 out << YAML ::EndMap;
0 commit comments