From b1040da379aee89642d7877ace7f191817fde267 Mon Sep 17 00:00:00 2001 From: nedko Date: Sat, 19 Feb 2005 21:02:34 +0000 Subject: [PATCH] Don't try to access database when it is not opened. --- gtk/medias.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/gtk/medias.c b/gtk/medias.c index c5b6097..b35ec0d 100644 --- a/gtk/medias.c +++ b/gtk/medias.c @@ -1,7 +1,7 @@ /* -*- Mode: C ; c-basic-offset: 2 -*- */ /***************************************************************************** * - * $Id: medias.c,v 1.5 2005/02/18 22:20:05 nedko Exp $ + * $Id: medias.c,v 1.6 2005/02/19 21:02:34 nedko Exp $ * * DESCRIPTION: * @@ -150,24 +150,27 @@ create_and_fill_model(void) G_TYPE_STRING, /* COL_MEDIALOCATION */ G_TYPE_STRING); /* COL_MEDIACOMMENT */ - r = mediadb_media_get_all( - g_hDB, - media_callback, - pStore); - if (MEDIADB_IS_ERROR(r)) + if (g_hDB != NULL) { - g_warning("%s\n", mediadb_get_error_message(g_hDB)); - - pDialog = gtk_message_dialog_new( - GTK_WINDOW(pMainWindow), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s", - mediadb_get_error_message(g_hDB)); - - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); + r = mediadb_media_get_all( + g_hDB, + media_callback, + pStore); + if (MEDIADB_IS_ERROR(r)) + { + g_warning("%s\n", mediadb_get_error_message(g_hDB)); + + pDialog = gtk_message_dialog_new( + GTK_WINDOW(pMainWindow), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + "%s", + mediadb_get_error_message(g_hDB)); + + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } } return GTK_TREE_MODEL(pStore); @@ -336,6 +339,9 @@ CreateMediasWindow() * !!! WARNING !!! Following lines are automatically updated by the CVS system. * * $Log: medias.c,v $ + * Revision 1.6 2005/02/19 21:02:34 nedko + * Don't try to access database when it is not opened. + * * Revision 1.5 2005/02/18 22:20:05 nedko * Cleanup things and make them better way. * -- 2.11.4.GIT