plug-ins: fix resource leak in psd-load
Adding unsupported messages was overwriting the old message without first freeing it. In addition, the first message was initialized as a string constant. We now start with duplicating the (empty) string, so that it can be freed. We then add a define to reduce boilerplate to add the string for each unsupported feature. The code in this define takes care of adding the new message and freeing the old message.
This commit is contained in:
parent
a9f642322d
commit
63bb893c06
1 changed files with 44 additions and 35 deletions
|
|
@ -3567,7 +3567,7 @@ load_dialog (const gchar *title,
|
|||
{
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *title_label;
|
||||
gchar *message = "";
|
||||
gchar *message = g_strdup ("");
|
||||
gchar *title = g_strdup_printf ("<b>%s</b>\n%s\n",
|
||||
_("Compatibility Notice"),
|
||||
_("This PSD file contains features "
|
||||
|
|
@ -3582,50 +3582,59 @@ load_dialog (const gchar *title,
|
|||
gtk_box_pack_start (GTK_BOX (vbox), title_label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (title_label);
|
||||
|
||||
#define ADD_UNSUPPORTED_MESSAGE(message, text) \
|
||||
{ \
|
||||
gchar *old_message = message; \
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", old_message, \
|
||||
_(text)); \
|
||||
g_free (old_message); \
|
||||
} \
|
||||
|
||||
if (unsupported_features->adjustment_layer)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Adjustment layers are not yet "
|
||||
"supported and will be dropped."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Adjustment layers are not yet "
|
||||
"supported and will be dropped.");
|
||||
if (unsupported_features->psd_metadata)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Metadata non-raster layers are "
|
||||
"not yet supported and will be dropped."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Metadata non-raster layers are "
|
||||
"not yet supported and will be dropped.");
|
||||
if (unsupported_features->fill_layer)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Fill layers are partially "
|
||||
"supported and will be converted "
|
||||
"to raster layers."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Fill layers are partially "
|
||||
"supported and will be converted "
|
||||
"to raster layers.");
|
||||
if (unsupported_features->text_layer)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Text layers are partially "
|
||||
"supported and will be converted "
|
||||
"to raster layers."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Text layers are partially "
|
||||
"supported and will be converted "
|
||||
"to raster layers.");
|
||||
if (unsupported_features->linked_layer)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Linked layers are not yet "
|
||||
"supported and will be dropped."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Linked layers are not yet "
|
||||
"supported and will be dropped.");
|
||||
if (unsupported_features->vector_mask)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Vector masks are partially "
|
||||
"supported and will be converted "
|
||||
"to raster layers."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Vector masks are partially "
|
||||
"supported and will be converted "
|
||||
"to raster layers.");
|
||||
if (unsupported_features->stroke)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Vector strokes are not yet "
|
||||
"supported and will be dropped."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Vector strokes are not yet "
|
||||
"supported and will be dropped.");
|
||||
if (unsupported_features->layer_effect)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Layer effects are not yet "
|
||||
"supported and will be dropped."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Layer effects are not yet "
|
||||
"supported and will be dropped.");
|
||||
if (unsupported_features->smart_object)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
_("Smart objects are not yet "
|
||||
"supported and will be dropped."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
"Smart objects are not yet "
|
||||
"supported and will be dropped.");
|
||||
if (unsupported_features->layer_comp)
|
||||
message = g_strdup_printf ("%s\n\xE2\x80\xA2 %s", message,
|
||||
/* Translators: short for layer compositions */
|
||||
_("Layer comps are not yet "
|
||||
"supported and will be dropped."));
|
||||
ADD_UNSUPPORTED_MESSAGE (message,
|
||||
/* Translators: short for layer compositions */
|
||||
"Layer comps are not yet "
|
||||
"supported and will be dropped.");
|
||||
#undef ADD_UNSUPPORTED_MESSAGE
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_set_size_request (scrolled_window, -1, 100);
|
||||
|
|
|
|||
Loading…
Reference in a new issue