From b265016b7504bc7b7dbb4bae10e38c50b89d7cb7 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 28 Oct 2017 18:58:08 -0400 Subject: mq_web_view_open(), mq_web_view_save(): Don't save NULL chooser folder Also free the return value of gtk_file_chooser_get_current_folder() and save the configuration in mq_web_view_open()'s callback. --- (limited to 'src') diff --git a/src/web-view.c b/src/web-view.c index b0c99a2..af69929 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -801,13 +801,19 @@ mq_web_view_zoom_reset(MqWebView *web_view) static void open_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view) { + gchar *dir; gchar *filename; gchar *uri; if (response_id == GTK_RESPONSE_ACCEPT) { - mq_config_set_string(web_view->config, "directories.open-file", - gtk_file_chooser_get_current_folder( - GTK_FILE_CHOOSER(dialog))); + dir = gtk_file_chooser_get_current_folder( + GTK_FILE_CHOOSER(dialog)); + if (dir) { + mq_config_set_string(web_view->config, + "directories.open-file", dir); + g_free(dir); + mq_config_save(web_view->config); + } filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog)); uri = g_strconcat("file://", filename, NULL); @@ -867,14 +873,19 @@ get_clean_title(MqWebView *web_view) static void save_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view) { + gchar *dir; gchar *filename; GFile *file; if (response_id == GTK_RESPONSE_ACCEPT) { - mq_config_set_string(web_view->config, "directories.downloads", - gtk_file_chooser_get_current_folder( - GTK_FILE_CHOOSER(dialog))); - mq_config_save(web_view->config); + dir = gtk_file_chooser_get_current_folder( + GTK_FILE_CHOOSER(dialog)); + if (dir) { + mq_config_set_string(web_view->config, + "directories.downloads", dir); + g_free(dir); + mq_config_save(web_view->config); + } filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog)); file = g_file_new_for_path(filename); -- cgit v0.9.1