Hi Paolo,
It seems that the crashes came when you free a GtkTreeIter or GtkTextIter, you use the free_oop_for_g_object function (in gst-gtk.c) but these are classical structures not GObject. Cheers, Gwenael -- GtkLauncher for GNU Smalltalk : http://gtklauncher.bioskop.fr/ _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Wednesday 29 April 2009 10:15:48 you wrote:
> Hi Paolo, > > It seems that the crashes came when you free a GtkTreeIter or GtkTextIter, > you use the free_oop_for_g_object function (in gst-gtk.c) but these are > classical structures not GObject. > > Cheers, > Gwenael Hmm forget what I say but the error is when you call : gtk_text_iter_free read in the gtk doc "The memory must have been allocated via g_slice_alloc() or g_slice_alloc0() and the block_size has to match the size specified upon allocation." Gwenael -- GtkLauncher for GNU Smalltalk : http://gtklauncher.bioskop.fr/ _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Gwenael Casaccio wrote:
> On Wednesday 29 April 2009 10:15:48 you wrote: >> Hi Paolo, >> >> It seems that the crashes came when you free a GtkTreeIter or GtkTextIter, >> you use the free_oop_for_g_object function (in gst-gtk.c) but these are >> classical structures not GObject. Almost there: I use gtk_tree_iter_free, but I allocate it with malloc instead of gtk_tree_iter_copy. This patch fixes half of it: diff --git a/packages/gtk/GtkImpl.st b/packages/gtk/GtkImpl.st index 4b32273..a383fb2 100644 --- a/packages/gtk/GtkImpl.st +++ b/packages/gtk/GtkImpl.st @@ -172,9 +172,16 @@ GdkRectangle extend [ GtkTreeIter class extend [ + Prototype := nil. + + gcNew [ + ^self type gcNew + ] + new [ <category: 'instance creation'> - ^(self type new) + Prototype isNil ifTrue: [ Prototype := self type gcNew ]. + ^Prototype copy addToBeFinalized; yourself ] @@ -185,9 +192,16 @@ GtkTreeIter class extend [ GtkTextIter class extend [ + Prototype := nil. + + gcNew [ + ^self type gcNew + ] + new [ <category: 'instance creation'> - ^(self type new) + Prototype isNil ifTrue: [ Prototype := self type gcNew ]. + ^Prototype copy addToBeFinalized; yourself ] Even then, GtkTreeIter>>#free do not set the object to point to NULL, which may cause double frees. So we need this too: diff --git a/packages/gtk/funcs.awk b/packages/gtk/funcs.awk index 340cfbf..0ca78f6 100644 --- a/packages/gtk/funcs.awk +++ b/packages/gtk/funcs.awk @@ -308,3 +308,10 @@ match_function_first_line($0) { + if (decl == "free") { + print "free" + print " (self isAbsolute and: [ self address > 0 ])" + print "\tifTrue: [ self primFree. self address: 0 ]!" + decl = "primFree" + } + print decl print " <cCall: '" cFuncName "' returning: " retType print "\targs: #(" argdecl " )>! !\n" Still, it's terribly inefficient to use finalization when GC could work instead. Many of the helper methods in packages/gtk/GtkImpl.st could use #gcNew instead of #new. I'm committing the above patches. Thanks! Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |