[gnome-db] GnomeDbGrid crashes when setting a GdaDataModel
- From: Javier Muņoz Ferrara <javierm aditel org>
- To: gnome-db-list gnome org
- Subject: [gnome-db] GnomeDbGrid crashes when setting a GdaDataModel
- Date: 18 Jul 2002 18:35:38 +0200
Hi!
I'm trying to use a GnomeDbGrid. I can create it whit
gnome_db_grid_new(), but when I asign it a GdaDataModel with
gnome_db_grid_set_model(GnomeDbGrid*, GdaDataModel*) it crashes
(segfault). I have tryied to use
gnome_db_grid_new_with_model(GdaDataModel*), but it crashes too. What am
I doing wrong?
I compile the code with:
$ gcc test.c -o test `pkg-config --libs -cflags libgnomedb`
I insert the code:
#include <gnome.h>
#include <libgda/libgda.h>
#include <libgnomedb/libgnomedb.h>
void show_model_gui(GdaDataModel *model)
{
GtkWidget* window;
GtkWidget* control;
GtkWidget *dbgrid1;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window), "destroy", gtk_main_quit, NULL);
dbgrid1=gnome_db_grid_new();
gnome_db_grid_set_model((GnomeDbGrid *)dbgrid1,model);
/* I don't add the grid to the window */
gtk_widget_show_all(window);
gtk_main();
}
void
funcion (void)
{
GdaClient *client;
GdaConnection *cnc;
GdaCommand *command;
GdaDataModel *model;
client = gda_client_new();
g_return_if_fail (GDA_IS_CLIENT (client));
cnc = gda_client_open_connection(client, "MyDataSource", "gda", "gdapass");
g_return_if_fail (GDA_IS_CONNECTION (cnc));
command = gda_command_new("SELECT * FROM rumbera",GDA_COMMAND_TYPE_SQL,0);
model = gda_connection_execute_single_command(cnc,command,NULL);
if (!GDA_IS_DATA_MODEL(model))
{
gnome_db_main_quit();
exit(0);
}
show_model_gui(model);
gda_connection_close(cnc);
g_object_unref (G_OBJECT (client));
gnome_db_main_quit();
}
int
main ( int argc, char * argv[])
{
gnome_db_init ("demo", "0.1", argc, argv);
g_print("Antes de main_run\n");
gnome_db_main_run ((GdaInitFunc) funcion , NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]