Fixed more crashes when MIME database is not initialized

This commit is contained in:
Pierre Pronchery 2007-04-29 22:23:02 +00:00
parent cf27f07836
commit e2c4a1a05f
2 changed files with 9 additions and 5 deletions

View File

@ -1036,7 +1036,10 @@ void browser_set_location(Browser * browser, char const * path)
if((realpath = _location_real_path(path)) == NULL) if((realpath = _location_real_path(path)) == NULL)
return; return;
if(g_file_test(realpath, G_FILE_TEST_IS_REGULAR)) if(g_file_test(realpath, G_FILE_TEST_IS_REGULAR))
{
if(browser->mime != NULL)
mime_action(browser->mime, "open", realpath); mime_action(browser->mime, "open", realpath);
}
else if(g_file_test(realpath, G_FILE_TEST_IS_DIR) else if(g_file_test(realpath, G_FILE_TEST_IS_DIR)
&& _location_directory(browser, realpath) == 0) && _location_directory(browser, realpath) == 0)
{ {

View File

@ -703,7 +703,7 @@ static void _default_do(Browser * browser, GtkTreePath * path)
&location, BR_COL_IS_DIRECTORY, &is_dir, -1); &location, BR_COL_IS_DIRECTORY, &is_dir, -1);
if(is_dir) if(is_dir)
browser_set_location(browser, location); browser_set_location(browser, location);
else else if(browser->mime != NULL)
mime_action(browser->mime, "open", location); mime_action(browser->mime, "open", location);
g_free(location); g_free(location);
} }
@ -968,7 +968,7 @@ static void _press_mime(Mime * mime, char const * mimetype, char const * action,
{ {
GtkWidget * menuitem; GtkWidget * menuitem;
if(mime_get_handler(mime, mimetype, action) == NULL) if(mime == NULL || mime_get_handler(mime, mimetype, action) == NULL)
return; return;
if(strncmp(label, "gtk-", 4) == 0) if(strncmp(label, "gtk-", 4) == 0)
menuitem = gtk_image_menu_item_new_from_stock(label, NULL); 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) if(cb->isdir)
browser_set_location(cb->browser, cb->path); browser_set_location(cb->browser, cb->path);
else else if(cb->browser->mime != NULL)
mime_action(cb->browser->mime, "open", cb->path); mime_action(cb->browser->mime, "open", cb->path);
} }
@ -1017,6 +1017,7 @@ static void _on_icon_edit(GtkWidget * widget, gpointer data)
{ {
IconCallback * cb = data; IconCallback * cb = data;
if(cb->browser->mime != NULL)
mime_action(cb->browser->mime, "edit", cb->path); mime_action(cb->browser->mime, "edit", cb->path);
} }