Re: [gtk-list] Re: bug in object destroy logic?





On Fri, 1 Aug 1997, Peter Mattis wrote:

> The slightly confusing part is that B inherits, it does not copy, the
> destroy method from C. Read up on virtual destructor's in C++. That is
> the way this mechanism is supposed to work. I attached a really short
> C++ example to the end of this message to give an example. Hopefully
> the gtk+ code is working the same way. (I think it is, I've purified
> gtk+ recently and I'm sure purify would have reported an error for
> attempting to free memory twice).

Indeed. I have egg on my face. I see it now - the destroy methods don't 
traverse the linked list induced by the parent_class pointers. Rather, 
each destroy method statically knows what its parent class is. So, when 
C's destroy method gets called in place of B, it knows that its parent is 
Object and not C. I checked this out in actual code (as I should have 
done in the first place), and it works like it's supposed to.

Duhh!

> Out of curiosity, did you encounter a bug in this code or is this
> something you just stumbled upon and thought it might be a bug?

The latter.

Here's another bug I have a bit more confidence in:

--- gtkaccelerator.c~	Sun Apr  6 23:52:50 1997
+++ gtkaccelerator.c	Sun Aug  3 19:32:40 1997
@@ -161,7 +161,7 @@
 	      signame = gtk_signal_name (entry->signal_num);
 	      gtk_signal_emit_by_name (entry->object,
 				       "remove_accelerator",
-				       signal_name);
+				       signame);
 	    }
 
 	  entry->modifiers = accelerator_mods;

This one was also a product of reading through the source. It's very
unlikely to cause a problem in practice, because the signal name is
"activate" almost all the time, but it could be a problem. The symptom
would be that an existing accelerator for a key would not be properly
removed if its signal name differs from the signal name of the new
accelerator. 

At some point, I'd like to go through the accelerator code, changing 
gchar key to guint keyval (matching that of GdkEventKey) so that function 
keys, arrow keys, Esc, etc. could all be used as accelerators. Does 
anyone have any strong feelings about this?

Raph



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