From e2c4a1a05fb4ac363c3578bb7f8cdcbf8361effc Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 29 Apr 2007 22:23:02 +0000 Subject: [PATCH] Fixed more crashes when MIME database is not initialized --- src/browser.c | 5 ++++- src/callbacks.c | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/browser.c b/src/browser.c index 06d31bc..f6f5b3b 100644 --- a/src/browser.c +++ b/src/browser.c @@ -1036,7 +1036,10 @@ void browser_set_location(Browser * browser, char const * path) if((realpath = _location_real_path(path)) == NULL) return; if(g_file_test(realpath, G_FILE_TEST_IS_REGULAR)) - mime_action(browser->mime, "open", realpath); + { + if(browser->mime != NULL) + mime_action(browser->mime, "open", realpath); + } else if(g_file_test(realpath, G_FILE_TEST_IS_DIR) && _location_directory(browser, realpath) == 0) { diff --git a/src/callbacks.c b/src/callbacks.c index 2382848..5a99038 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -703,7 +703,7 @@ static void _default_do(Browser * browser, GtkTreePath * path) &location, BR_COL_IS_DIRECTORY, &is_dir, -1); if(is_dir) browser_set_location(browser, location); - else + else if(browser->mime != NULL) mime_action(browser->mime, "open", location); g_free(location); } @@ -968,7 +968,7 @@ static void _press_mime(Mime * mime, char const * mimetype, char const * action, { GtkWidget * menuitem; - if(mime_get_handler(mime, mimetype, action) == NULL) + if(mime == NULL || mime_get_handler(mime, mimetype, action) == NULL) return; if(strncmp(label, "gtk-", 4) == 0) menuitem = gtk_image_menu_item_new_from_stock(label, NULL); @@ -1009,7 +1009,7 @@ static void _on_icon_open(GtkWidget * widget, gpointer data) if(cb->isdir) browser_set_location(cb->browser, cb->path); - else + else if(cb->browser->mime != NULL) mime_action(cb->browser->mime, "open", cb->path); } @@ -1017,7 +1017,8 @@ static void _on_icon_edit(GtkWidget * widget, gpointer data) { IconCallback * cb = data; - mime_action(cb->browser->mime, "edit", cb->path); + if(cb->browser->mime != NULL) + mime_action(cb->browser->mime, "edit", cb->path); } static void _on_icon_open_with(GtkWidget * widget, gpointer data)