cinera.c: Fix role-related bugs

•   Fix segfault due to unconfigured role
•   Add credit scope to the root scope's TypeSpec, permitting
        credit = "$owner" { role = "host"; }
    to be absorbed by all projects
•   Make "unfound role" errors WaitForInput()
This commit is contained in:
Matt Mascarenhas 2021-05-31 19:20:52 +01:00
parent a6a9653306
commit cf51ba24e3
2 changed files with 12 additions and 4 deletions

View File

@ -23,7 +23,7 @@ typedef struct
version CINERA_APP_VERSION = { version CINERA_APP_VERSION = {
.Major = 0, .Major = 0,
.Minor = 8, .Minor = 8,
.Patch = 12 .Patch = 13
}; };
#include <stdarg.h> // NOTE(matt): varargs #include <stdarg.h> // NOTE(matt): varargs
@ -6904,7 +6904,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData *
for(int ProjectCreditIndex = 0; ProjectCreditIndex < CurrentProject->Credit.ItemCount; ++ProjectCreditIndex) for(int ProjectCreditIndex = 0; ProjectCreditIndex < CurrentProject->Credit.ItemCount; ++ProjectCreditIndex)
{ {
credit *Credit = GetPlaceInBook(&CurrentProject->Credit, ProjectCreditIndex); credit *Credit = GetPlaceInBook(&CurrentProject->Credit, ProjectCreditIndex);
if(!Uncredited(Metadata, Credit) && !GetCredit(Credits, Credit)) if(!Uncredited(Metadata, Credit) && Credit->Role && !GetCredit(Credits, Credit))
{ {
credit *New = MakeSpaceInBook(Credits); credit *New = MakeSpaceInBook(Credits);
New->Person = Credit->Person; New->Person = Credit->Person;
@ -6918,7 +6918,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData *
credit Credit = {}; credit Credit = {};
Credit.Person = GetPersonFromConfig(Wrap0(This->name)); Credit.Person = GetPersonFromConfig(Wrap0(This->name));
Credit.Role = GetRoleByID(Config, Wrap0(This->role)); Credit.Role = GetRoleByID(Config, Wrap0(This->role));
if(!Uncredited(Metadata, &Credit) && !GetCredit(Credits, &Credit)) if(!Uncredited(Metadata, &Credit) && Credit.Role && !GetCredit(Credits, &Credit))
{ {
credit *New = MakeSpaceInBook(Credits); credit *New = MakeSpaceInBook(Credits);
New->Person = Credit.Person; New->Person = Credit.Person;
@ -6937,7 +6937,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData *
credit Credit = {}; credit Credit = {};
Credit.Person = GetPersonFromConfig(Wrap0(This->value)); Credit.Person = GetPersonFromConfig(Wrap0(This->value));
Credit.Role = GetRoleByID(Config, Wrap0(RoleIDStrings[ThisAttribute->RoleID])); Credit.Role = GetRoleByID(Config, Wrap0(RoleIDStrings[ThisAttribute->RoleID]));
if(!Uncredited(Metadata, &Credit) && !GetCredit(Credits, &Credit)) if(!Uncredited(Metadata, &Credit) && Credit.Role && !GetCredit(Credits, &Credit))
{ {
credit *New = MakeSpaceInBook(Credits); credit *New = MakeSpaceInBook(Credits);
New->Person = Credit.Person; New->Person = Credit.Person;

View File

@ -946,6 +946,7 @@ InitTypeSpecs(void)
PushTypeSpecField(Root, FT_BOOLEAN, IDENT_SINGLE_BROWSER_TAB, TRUE); PushTypeSpecField(Root, FT_BOOLEAN, IDENT_SINGLE_BROWSER_TAB, TRUE);
PushTypeSpecField(Root, FT_BOOLEAN, IDENT_SUPPRESS_PROMPTS, TRUE); PushTypeSpecField(Root, FT_BOOLEAN, IDENT_SUPPRESS_PROMPTS, TRUE);
PushTypeSpecField(Root, FT_NUMBER, IDENT_PRIVACY_CHECK_INTERVAL, TRUE); PushTypeSpecField(Root, FT_NUMBER, IDENT_PRIVACY_CHECK_INTERVAL, TRUE);
PushTypeSpecField(Root, FT_SCOPE, IDENT_CREDIT, FALSE);
PushTypeSpecField(Root, FT_SCOPE, IDENT_INCLUDE, FALSE); PushTypeSpecField(Root, FT_SCOPE, IDENT_INCLUDE, FALSE);
PushTypeSpecField(Root, FT_SCOPE, IDENT_MEDIUM, FALSE); PushTypeSpecField(Root, FT_SCOPE, IDENT_MEDIUM, FALSE);
PushTypeSpecField(Root, FT_SCOPE, IDENT_PERSON, FALSE); PushTypeSpecField(Root, FT_SCOPE, IDENT_PERSON, FALSE);
@ -2702,6 +2703,7 @@ GetRole(config *C, resolution_errors *E, config_pair *RoleID)
string Filepath = Wrap0(RoleID->Position.Filename); string Filepath = Wrap0(RoleID->Position.Filename);
ConfigError(&Filepath, RoleID->Position.LineNumber, S_WARNING, "Could not find role: ", &RoleID->Value); ConfigError(&Filepath, RoleID->Position.LineNumber, S_WARNING, "Could not find role: ", &RoleID->Value);
PushError(E, S_WARNING, &RoleID->Position, IDENT_ROLE); PushError(E, S_WARNING, &RoleID->Position, IDENT_ROLE);
WaitForInput();
} }
return Result; return Result;
} }
@ -2719,6 +2721,12 @@ GetRoleByID(config *C, string ID)
break; break;
} }
} }
if(!Result)
{
ConfigError(0, 0, S_WARNING, "Could not find role: ", &ID);
WaitForInput();
}
return Result; return Result;
} }