Commit 4fdf301d authored by Jehan's avatar Jehan
Browse files

plug-ins: properly check widget class holding tag data.

Some tag data is hold in GtkEntry, other in GtkTextView, which are not
parent to each other. Previous checks were wrong and resulted in
"invalid cast from 'GtkEntry' to 'GtkTextView'" WARNINGs (followed by
many CRITICALs because of this first error).

Also properly free the data returned by gtk_text_buffer_get_text() which
is allocated (unlike strings returned by gtk_entry_get_text() which must
not be freed).
parent 8aaf77ba
......@@ -877,28 +877,29 @@ hasPropertyReleaseTagData (GtkBuilder *builder)
hasCreatorTagData (GtkBuilder *builder)
gint loop;
gboolean has_data = FALSE;
gint loop;
for (loop = 0; loop < creatorContactInfoHeader.size; loop++)
GObject *object;
const gchar *text;
GObject *object;
object = gtk_builder_get_object (builder, default_metadata_tags[loop].tag);
if (! strcmp (creatorContactInfoTags[loop].mode, "single"))
if (GTK_IS_ENTRY (object))
text = gtk_entry_get_text (GTK_ENTRY (object));
const gchar *text = gtk_entry_get_text (GTK_ENTRY (object));
if (text && *text)
return TRUE;
has_data = TRUE;
else if (! strcmp (creatorContactInfoTags[loop].mode, "multi"))
else if (GTK_IS_TEXT_VIEW (object))
GtkTextView *text_view = GTK_TEXT_VIEW (object);
GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view);
GtkTextIter start;
GtkTextIter end;
gchar *text;
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
......@@ -906,11 +907,14 @@ hasCreatorTagData (GtkBuilder *builder)
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
if (text && *text)
return TRUE;
has_data = TRUE;
if (text)
g_free (text);
return FALSE;
return has_data;
/* ============================================================================
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment