This is the mail archive of the guile-gtk@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: implementing guile-gtk drag & drop...


 
> Because I don't understand what is the problem...(blame my very poor
> knowledge of guile-gtk and gtk)

  Gtk+ uses reference counting to protect some (!) data - GtkWidgets and so on.
Reference counter is increased when someone wants to "work" with object, counter
is decreased when "user" does not want to use it anymore. When reference counter
drops to zero, Gtk+ object is destroyed.

  Guile uses mark and sweep garbage collector - when GC is invoked, all
"referenced" data are marked and unmarked data are destroyed.

  Guile-gtk has to combine both strategies. When SMOB wraps Gtk object, it
increments counter, when smob is destroyed (nobody use scheme object), counter
is decremented. In fact the situation is a little bit more complicated (because
of callbacks etc), but I hope you got the picture.

  The problem with GtkSelectionData is following: since it does not have
reference counter, multiple "users" (parts of code) can not reference it,
because they do not know how many users it really has and when to destroy
it. You even do not know if you use already "destroyed" GtkSelectionData. You
can not protect it using counter and there is no way how to get to know when
object was destroyed (so you could invalidate it).

  The sad part of the story is, that you even can not copy GtkSelectionData and
work on your local copy - DnD will not work :-(

  My temporal solution is to be "blind" - I presume that nobody wants to shoot
into his foot and GtkSelectionData will be only referenced when it really exists
(otherwise it is the source of possible SIGSEGV..)

0.

ps: If you want to learn more about GC, look for paper by Paul R. Wilson:
Uniprocessor Garbage Collection Techniques.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]