]> saetta.ns0.it Git - zakaudit/gui/commitdiff
Bugfix deletion: wrong gda statement check. gtk3
authorAndrea Zagli <azagli@libero.it>
Sun, 17 Dec 2017 21:26:21 +0000 (22:26 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 17 Dec 2017 21:26:21 +0000 (22:26 +0100)
src/datasources.c

index e695e948dd202da19872857585b7f19c93f3b206..f5927304bcabfcaf190d082bd07d600ebd8088fd 100644 (file)
@@ -1223,41 +1223,45 @@ datasources_on_btn_delete_clicked (GtkButton *button,
                                        if (id != 0)
                                                {
                                                        stmt = gda_sql_parser_parse_string (priv->commons->gdaparser,
-                                                                           g_strdup_printf ("UPDATE %sdatasources SET status = 'D' WHERE id = %d", priv->commons->prefix, id),
-                                                                           NULL, NULL);
+                                                                                           g_strdup_printf ("UPDATE %sdatasources SET status = 'D' WHERE id = %d", priv->commons->prefix, id),
+                                                                                           NULL, NULL);
                                                }
                                        else
                                                {
                                                        gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_datasources), &iter,
-                                                           COL_ID_TABLE, &id,
-                                                           -1);
+                                                                           COL_ID_TABLE, &id,
+                                                                           -1);
                                                        if (id != 0)
                                                                {
                                                                        stmt = gda_sql_parser_parse_string (priv->commons->gdaparser,
-                                                                           g_strdup_printf ("UPDATE %stables SET status = 'D' WHERE id = %d", priv->commons->prefix, id),
-                                                                           NULL, NULL);
-
+                                                                                                           g_strdup_printf ("UPDATE %stables SET status = 'D' WHERE id = %d", priv->commons->prefix, id),
+                                                                                                           NULL, NULL);
                                                                }
                                                }
 
-                                       if (stmt != NULL)
+                                       if (stmt == NULL)
                                                {
+                                                       gtk_widget_destroy (dialog);
                                                        dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
-                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                        GTK_MESSAGE_WARNING,
-                                                        GTK_BUTTONS_OK,
-                                                        _("You must select a datasource or a table."));
+                                                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                                                        GTK_MESSAGE_WARNING,
+                                                                                        GTK_BUTTONS_OK,
+                                                                                        _("You must select a datasource or a table."));
+                                                       gtk_dialog_run (GTK_DIALOG (dialog));
+                                                       gtk_widget_destroy (dialog);
                                                        return;
                                                }
 
                                        if (gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error) <= 0)
                                                {
+                                                       gtk_widget_destroy (dialog);
                                                        dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
-                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                        GTK_MESSAGE_WARNING,
-                                                        GTK_BUTTONS_OK,
-                                                        _("Error on saving.\n\n%s"),
-                                                        (error != NULL && error->message != NULL ? error->message : _("No details.")));
+                                                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                                                        GTK_MESSAGE_WARNING,
+                                                                                        GTK_BUTTONS_OK,
+                                                                                        _("Error on saving.\n\n%s"),
+                                                                                        (error != NULL && error->message != NULL ? error->message : _("No details.")));
+                                                       gtk_dialog_run (GTK_DIALOG (dialog));
                                                }
 
                                        datasources_load (datasources);