Skip to content

Commit 074a091

Browse files
tenderloveTurboGit
authored andcommitted
Add a default name for styles that don't have a name
This adds a default name `imported-style` to imported style files that don't have a name. All styles need to have a name, so just in case the XML doesn't include one this commit will add a default name that the user can edit later.
1 parent a21d93a commit 074a091

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/common/styles.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,14 @@ static void dt_styles_style_text_handler(GMarkupParseContext *context,
14701470

14711471
if(g_ascii_strcasecmp(elt, "name") == 0)
14721472
{
1473-
g_string_append_len(style->info->name, text, text_len);
1473+
if (text_len == 0)
1474+
{
1475+
g_string_append(style->info->name, _("imported-style"));
1476+
}
1477+
else
1478+
{
1479+
g_string_append_len(style->info->name, text, text_len);
1480+
}
14741481
}
14751482
else if(g_ascii_strcasecmp(elt, "description") == 0)
14761483
{
@@ -1782,6 +1789,16 @@ gchar *dt_get_style_name(const char *filename)
17821789
dt_print(DT_DEBUG_CONTROL,
17831790
"[styles] file %s is a malformed style file", filename);
17841791
}
1792+
else
1793+
{
1794+
if(strlen(bname) == 0)
1795+
{
1796+
dt_print(DT_DEBUG_CONTROL,
1797+
"[styles] file %s is a malformed style file (with an empty name)", filename);
1798+
g_free(bname);
1799+
bname = g_strdup(_("imported-style"));
1800+
}
1801+
}
17851802
return bname;
17861803
}
17871804

0 commit comments

Comments
 (0)