From cf51ba24e3db837107cda2794fa3bc0185dcda26 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Mon, 31 May 2021 19:20:52 +0100 Subject: [PATCH] cinera.c: Fix role-related bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • 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() --- cinera/cinera.c | 8 ++++---- cinera/cinera_config.c | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cinera/cinera.c b/cinera/cinera.c index 8f76dbf..8258453 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -23,7 +23,7 @@ typedef struct version CINERA_APP_VERSION = { .Major = 0, .Minor = 8, - .Patch = 12 + .Patch = 13 }; #include // NOTE(matt): varargs @@ -6904,7 +6904,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData * for(int ProjectCreditIndex = 0; ProjectCreditIndex < CurrentProject->Credit.ItemCount; ++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); New->Person = Credit->Person; @@ -6918,7 +6918,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData * credit Credit = {}; Credit.Person = GetPersonFromConfig(Wrap0(This->name)); 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); New->Person = Credit.Person; @@ -6937,7 +6937,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData * credit Credit = {}; Credit.Person = GetPersonFromConfig(Wrap0(This->value)); 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); New->Person = Credit.Person; diff --git a/cinera/cinera_config.c b/cinera/cinera_config.c index 31cf241..6f5314d 100644 --- a/cinera/cinera_config.c +++ b/cinera/cinera_config.c @@ -946,6 +946,7 @@ InitTypeSpecs(void) PushTypeSpecField(Root, FT_BOOLEAN, IDENT_SINGLE_BROWSER_TAB, TRUE); PushTypeSpecField(Root, FT_BOOLEAN, IDENT_SUPPRESS_PROMPTS, 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_MEDIUM, 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); ConfigError(&Filepath, RoleID->Position.LineNumber, S_WARNING, "Could not find role: ", &RoleID->Value); PushError(E, S_WARNING, &RoleID->Position, IDENT_ROLE); + WaitForInput(); } return Result; } @@ -2719,6 +2721,12 @@ GetRoleByID(config *C, string ID) break; } } + + if(!Result) + { + ConfigError(0, 0, S_WARNING, "Could not find role: ", &ID); + WaitForInput(); + } return Result; }