Commit ae34e941b2824f6947e31001aa8af33603883327
1 parent
975128fa
Exists in
master
and in
1 other branch
Backporting for old versions of glib.
Showing
2 changed files
with
41 additions
and
29 deletions
Show diff stats
src/dialogs/colorscheme.c
| ... | ... | @@ -272,38 +272,49 @@ |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // Load color schemes. |
| 275 | - g_autoptr(GKeyFile) conf = g_key_file_new(); | |
| 276 | - g_autoptr(GError) err = NULL; | |
| 277 | - int index = 0; | |
| 278 | - gsize len; | |
| 279 | - gsize g; | |
| 275 | + GKeyFile * conf = g_key_file_new(); | |
| 276 | + GError * error = NULL; | |
| 277 | + int index = 0; | |
| 278 | + gsize len; | |
| 279 | + gsize g; | |
| 280 | 280 | |
| 281 | - g_key_file_load_from_file(conf,filename,G_KEY_FILE_NONE,&err); | |
| 281 | + g_key_file_load_from_file(conf,filename,G_KEY_FILE_NONE,&error); | |
| 282 | 282 | |
| 283 | - gchar **group = g_key_file_get_groups(conf,&len); | |
| 284 | - GTK_V3270_COLOR_SCHEME(widget)->schemes = g_new0(GdkRGBA,(len*V3270_COLOR_COUNT)); | |
| 285 | - | |
| 286 | - for(g=0;g<len;g++) | |
| 283 | + if(error) | |
| 287 | 284 | { |
| 288 | - // Setup colors for current entry | |
| 289 | - GtkTreeIter iter; | |
| 290 | - GdkRGBA * clr = GTK_V3270_COLOR_SCHEME(widget)->schemes+index; | |
| 291 | - const gchar * label = g_key_file_get_locale_string(conf,group[g],"label",NULL,NULL); | |
| 292 | - | |
| 293 | - load_color_scheme(conf,group[g],clr); | |
| 294 | - | |
| 295 | - // Set it in the combobox | |
| 296 | - gtk_list_store_append((GtkListStore *) model,&iter); | |
| 297 | - gtk_list_store_set((GtkListStore *) model, &iter, | |
| 298 | - 0, label ? label : group[g], | |
| 299 | - 1, clr, | |
| 300 | - -1); | |
| 301 | - | |
| 302 | - // move to next color list | |
| 303 | - index += V3270_COLOR_COUNT; | |
| 285 | + g_message("Can't load %s: %s",filename,error->message); | |
| 286 | + g_error_free(error); | |
| 287 | + } | |
| 288 | + else | |
| 289 | + { | |
| 290 | + gchar **group = g_key_file_get_groups(conf,&len); | |
| 291 | + GTK_V3270_COLOR_SCHEME(widget)->schemes = g_new0(GdkRGBA,(len*V3270_COLOR_COUNT)); | |
| 292 | + | |
| 293 | + for(g=0;g<len;g++) | |
| 294 | + { | |
| 295 | + // Setup colors for current entry | |
| 296 | + GtkTreeIter iter; | |
| 297 | + GdkRGBA * clr = GTK_V3270_COLOR_SCHEME(widget)->schemes+index; | |
| 298 | + const gchar * label = g_key_file_get_locale_string(conf,group[g],"label",NULL,NULL); | |
| 299 | + | |
| 300 | + load_color_scheme(conf,group[g],clr); | |
| 301 | + | |
| 302 | + // Set it in the combobox | |
| 303 | + gtk_list_store_append((GtkListStore *) model,&iter); | |
| 304 | + gtk_list_store_set((GtkListStore *) model, &iter, | |
| 305 | + 0, label ? label : group[g], | |
| 306 | + 1, clr, | |
| 307 | + -1); | |
| 308 | + | |
| 309 | + // move to next color list | |
| 310 | + index += V3270_COLOR_COUNT; | |
| 311 | + } | |
| 312 | + | |
| 313 | + g_strfreev(group); | |
| 314 | + | |
| 304 | 315 | } |
| 305 | 316 | |
| 306 | - g_strfreev(group); | |
| 317 | + g_key_file_free(conf); | |
| 307 | 318 | |
| 308 | 319 | return widget; |
| 309 | 320 | } | ... | ... |
src/v3270/callbacks.c
| ... | ... | @@ -329,8 +329,8 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const |
| 329 | 329 | |
| 330 | 330 | static int print(H3270 *session, LIB3270_PRINT_MODE mode) |
| 331 | 331 | { |
| 332 | - GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 333 | - g_autoptr(GError) error = NULL; | |
| 332 | + GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 333 | + GError * error = NULL; | |
| 334 | 334 | |
| 335 | 335 | v3270_print(widget, mode, &error); |
| 336 | 336 | |
| ... | ... | @@ -349,6 +349,7 @@ static int print(H3270 *session, LIB3270_PRINT_MODE mode) |
| 349 | 349 | gtk_dialog_run(GTK_DIALOG(dialog)); |
| 350 | 350 | gtk_widget_destroy(dialog); |
| 351 | 351 | |
| 352 | + g_error_free(error); | |
| 352 | 353 | return -1; |
| 353 | 354 | |
| 354 | 355 | } | ... | ... |