Re: [gnome-db] More fun with apps



On Wed, 2001-09-05 at 18:04, will lashell net wrote:
> <SNIP>
> > >
> > this is not needed, since the call to gda_command_execute below will
> > create the GdaRecordset
> 
> Hrmm, your example code and documentation should be changed to reflect
> this then.
> 
yes, I guess it's time to write good devel documentation. Where did you
see that code, so that I change it?

> > 
> > > 	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);
> 
> Well, in reply to another email, you said that if we use a grid, you basically
> have to free the resultset to do anything. This is broken in my opinion because
> i very likely will want to do something different to the resultset and shouldn't
> have to query the dbms again to get a new one
>
hmm, did I say that? What I meant is that when you associate a
GdaRecordset with a GnomeDbGrid (gnome_db_grid_set_recordset), you need
to gda_recordset_free the recordset yourself somewhere in your code.
That is, in gnome_db_grid_set_recordset, the recordset is
gtk_object_ref'ed, so there are 2 references to the recordset after
calling gnome_db_grid_set_recordset. That's why you need to call
gda_recordset_free on the recordset when no longer needed, to avoid
memory leakage.

Of course, until you call gda_recordset_free, the GdaRecordset is shared
between your code and the GnomeDbGrid widget. And traversing again the
recordset does not get the data again from the database, since it is
already in the cache.
 
> > > 
> > > 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)
> 
> Cool! What's the word on the release you've been planning?
> 
I'm preparing 2, the stable, and the unstable one. I hope to have at
least one of them (the unstable one) by the weekend.

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]