diff options
author | jstebbins <[email protected]> | 2009-07-17 17:06:25 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-07-17 17:06:25 +0000 |
commit | c6de8f05897b5232afd4bdc58fbcdc39b0078a8e (patch) | |
tree | b0b49a83225c4f2920fadc88d0731c9832fdfb6d /gtk | |
parent | a8acbe50c4fef4efd39d83e8052f1012fae7232a (diff) |
LinGui: a better solution to the g_io_channel_write_chars abort
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2704 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index e83a54a8f..85ec34339 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -2618,7 +2618,7 @@ G_MODULE_EXPORT gboolean ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data) { gchar *text = NULL; - gsize length; + gsize length, outlength; GtkTextView *textview; GtkTextBuffer *buffer; GtkTextIter iter; @@ -2629,7 +2629,11 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data) signal_user_data_t *ud = (signal_user_data_t*)data; status = g_io_channel_read_line (source, &text, &length, NULL, &gerror); - if (text != NULL && length > 0 && text[length-1] != 0) + // Trim nils from end of text, they cause g_io_channel_write_chars to + // fail with an assertion that aborts + while (length > 0 && text[length-1] == 0) + length--; + if (text != NULL && length > 0) { GdkWindow *window; gint width, height; @@ -2673,7 +2677,7 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data) text[length-1] = '\r'; #endif g_io_channel_write_chars (ud->activity_log, text, - length, &length, NULL); + length, &outlength, NULL); #if defined(_WIN32) g_io_channel_write_chars (ud->activity_log, "\n", one, &one, NULL); @@ -2682,15 +2686,17 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data) if (ud->job_activity_log) { g_io_channel_write_chars (ud->job_activity_log, text, - length, &length, NULL); + length, &outlength, NULL); #if defined(_WIN32) g_io_channel_write_chars (ud->activity_log, "\n", - one, &one, NULL); + one, &outlength, NULL); #endif g_io_channel_flush(ud->job_activity_log, NULL); } - g_free(text); } + if (text != NULL) + g_free(text); + if (status != G_IO_STATUS_NORMAL) { // This should never happen, but if it does I would get into an |