Re: [gnome-db] More fun with apps



On Wed, 2001-09-05 at 03:40, will lashell net wrote:
> Hrmm okay so here is a piece of code i'm using:
> 
> static void
> refresh_clist( GtkWidget *widget, gpointer data )
> {
> 	gulong reccount, blah;
> /*	char *foo[3]; */
> 	GdaRecordset *rs;
> 	GdaConnection *conn;
> 	GdaCommand *cmd;
> 	
> 	conn = gda_connection_new( gda_corba_get_orb() );
> 	gda_connection_set_provider( conn, "OAFIID:GNOME_GDA_Provider_MySQL_ConnectionFactory");
> 	if( gda_connection_open ( conn, "HOST=dev.ofsloans.com;DATABASE=message;PORT=3306", NULL, NULL) ) 
> 	{
>         GList *errors;
>         GList *node;
>         GdaError *error;
> 
>         errors = gda_connection_get_errors(conn);
>         for (node = g_list_first(errors); node; node = g_list_next(node)) 
> {
>                 error = (GdaError *) node->data;
>                 g_print("%s\n", gda_error_description( error) );
>         }
>         gda_error_list_free(errors);
> 	}
> 	else
> 	{
> 
> 	rs = gda_recordset_new();	
>
this is not needed, since the call to gda_command_execute below will
create the GdaRecordset

> 	cmd = gda_command_new ();
> 	gda_command_set_connection (cmd, conn);
> 	gda_command_set_text (cmd, "SELECT * FROM message where recipient = 'wlashell' order by date DESC");
> 	rs = gda_command_execute (cmd, &reccount, blah);
> 	
> 	gtk_clist_clear( GTK_CLIST( msg_list ) );
> 	printf( "query successful\n" );
> 	while( ! gda_recordset_eof( GDA_RECORDSET(rs) ) )
> 	{
> /*		foo[0] = row_data[4];
> 		foo[1] = row_data[2];
> 		foo[2] = row_data[5]; 
> 		gtk_clist_append( GTK_CLIST( msg_list ), foo); */
> 		gda_recordset_move_next( rs );
> 	}
> 	}
> }
> 
instead of this, why don't you use the GnomeDbGrid widget? It uses also
a GtkCList, and does everything for you. You just have to associate a
GdaRecordset with it:

GtkWidget *grid;

grid = gnome_db_grid_new (rs);

> 
> which compiles just fine. but.. we get a segfault when it tries to 
> execute.
> I ran a backtrace and this is what I ended up with:
> 
> 0x407b6dd3 in strlen () from /lib/i686/libc.so.6
> (gdb) bt
> #0  0x407b6dd3 in strlen () from /lib/i686/libc.so.6
> #1  0x40460251 in GDA_Connection_open () from /usr/lib/libgda-client.so.0
> #2  0x40466174 in gda_connection_open () from /usr/lib/libgda-client.so.0
> 
ok, the problem seems here, in the CORBA code. Let me see.... yes, in
this case, it was passing NULL values to the ORBit-generated functions,
and there, a call to strlen with a NULL pointer made it crash.

It's now fixed in CVS (gnome-1-x-branch CVS branch)

cheers
-- 
Rodrigo Moya <rodrigo gnome-db org> - <rodrigo ximian com>
http://www.gnome-db.org/ - http://www.ximian.com/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]