From c33682b3abf953d449f78f6d16a91bc4781d8d3f Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Wed, 17 Jan 2018 21:16:42 +0100 Subject: Properly support palettes without color names - use hexadecimal color code as a replacement in this case. - do not attempt to translate empty string / color name - fix an issue in the custom trim() function returning early for strings only consisting of a single whitespace character, e.g. "\n" Fixed bug: - https://bugs.launchpad.net/inkscape/+bug/1743708 --- src/ui/dialog/swatches.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index c6ab06507..d4d26e601 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "swatches.h" @@ -380,7 +381,7 @@ static char* trim( char* str ) { str++; } str--; - while ( str > ret && (( *str == ' ' || *str == '\t' ) || *str == '\r' || *str == '\n') ) { + while ( str >= ret && (( *str == ' ' || *str == '\t' ) || *str == '\r' || *str == '\n') ) { *str-- = 0; } return ret; @@ -453,9 +454,16 @@ void _loadPaletteFile(Glib::ustring path, gboolean user/*=FALSE*/) } if ( !hasErr && *ptr ) { char* n = trim(ptr); - if (n != NULL) { + if (n != NULL && *n) { name = g_dpgettext2(NULL, "Palette", n); } + if (name == "") { + name = Glib::ustring::compose("#%1%2%3", + Glib::ustring::format(std::hex, std::setw(2), std::setfill(L'0'), r), + Glib::ustring::format(std::hex, std::setw(2), std::setfill(L'0'), g), + Glib::ustring::format(std::hex, std::setw(2), std::setfill(L'0'), b) + ).uppercase(); + } } if ( !hasErr ) { // Add the entry now -- cgit v1.2.3