[discover client] Remove device from discover array before notifying UI
authorJeremy Kerr <jk@ozlabs.org>
Sun, 1 Feb 2009 05:28:38 +0000 (16:28 +1100)
committerJeremy Kerr <jk@ozlabs.org>
Sun, 1 Feb 2009 05:28:38 +0000 (16:28 +1100)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/common/discover-client.c

index 7c2e27daa777a4ddbb8cb4e4063b090c70e8cc52..ff0ab4031928155ce8ed35038b435ca022feb6a8 100644 (file)
@@ -107,10 +107,6 @@ static void remove_device(struct discover_client *client, const char *id)
        if (!device)
                return;
 
-       client->ops.remove_device(device, client->ops.cb_arg);
-
-       talloc_free(device);
-
        /* remove the device from the client's device array */
        client->n_devices--;
        memmove(&client->devices[i], &client->devices[i+1],
@@ -118,6 +114,10 @@ static void remove_device(struct discover_client *client, const char *id)
        client->devices = talloc_realloc(client, client->devices,
                        struct device *, client->n_devices);
 
+       /* notify the UI */
+       client->ops.remove_device(device, client->ops.cb_arg);
+
+       talloc_free(device);
 }
 
 int discover_client_process(struct discover_client *client)