changeset 2649:d891ba4be5a5

fixed crash when prefs window was closed while scanning
author Paula Stanciu <paula.stanciu@gmail.com>
date Sun, 25 May 2008 23:04:33 +0300
parents 6cc858a726b8
children a975b098485c
files src/bluetooth/bluetooth.c src/bluetooth/gui.c
diffstat 2 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/bluetooth/bluetooth.c	Sun May 25 21:44:27 2008 +0300
+++ b/src/bluetooth/bluetooth.c	Sun May 25 23:04:33 2008 +0300
@@ -28,7 +28,7 @@
 
 GeneralPlugin bluetooth_gp =
 {
-    .description = "Bluetooth audio suport",
+    .description = "Bluetooth audio support",
     .init = bluetooth_init,
     .about = bt_about,
     .configure = bt_cfg,
@@ -45,8 +45,10 @@
 void bluetooth_cleanup ( void )
 {
     printf("bluetooth: exit\n");
-    dbus_g_connection_flush (bus);
-    dbus_g_connection_unref(bus);
+    if(discover_finish == 2) {
+        dbus_g_connection_flush (bus);
+        dbus_g_connection_unref(bus);
+    }
 
 }
 /*void bt_cfg( void )
@@ -61,7 +63,7 @@
 
 
 void refresh_call(void){
-   if(discover_finish == 0)
+   if(discover_finish == 0 ||discover_finish== 2)
        discover_devices();
        else 
            printf("Scanning please wait!\n");
@@ -147,9 +149,7 @@
 {
     g_print("Signal: DiscoveryCompleted()\n");
     print_results();
-    discover_finish =0;
-
-
+    discover_finish =2;
 }
 
 
@@ -189,6 +189,6 @@
         g_error_free(error);
         exit(EXIT_FAILURE);
     }
-    // /  dbus_g_connection_flush (bus);
-    //    dbus_g_connection_unref(bus);
+      dbus_g_connection_flush (bus);
+      dbus_g_connection_unref(bus);
 }    
--- a/src/bluetooth/gui.c	Sun May 25 21:44:27 2008 +0300
+++ b/src/bluetooth/gui.c	Sun May 25 23:04:33 2008 +0300
@@ -60,6 +60,8 @@
     gint dev_no=0;
     GList *dev;
     gchar *temp;
+    if(!window) 
+        return NULL;
    /* create list store */
     store = gtk_list_store_new(NUM_COLUMNS,
             G_TYPE_STRING);
@@ -102,6 +104,8 @@
 
 void refresh_tree()
 {
+    if(!window) 
+        return;
      model = rebuild_model();
      gtk_tree_view_set_model(GTK_TREE_VIEW(treeview),GTK_TREE_MODEL(model));
 }