Re: GTK_WINDOW(NULL) (WAS: more patches)



Owen Taylor <otaylor redhat com> writes:
> > The cast macros are intended in part to verify that the object exists
> > and is non-NULL, there's no point in using them for NULL objects (you
> > can't check the type of NULL anyhow).
> 
> The GTK_IS_FOO() checks are meant to verify that the object exists and
> is valid.
> 
> The cast macros are just meant to be a safe versions of '(GtkFoo*)pointer'
> that warn for invalid casts between types.

Since they check for NULL, I'm not sure they are meant to be that at
the moment. ;-)

> But assigning
> NULL to a GtkFoo * is perfectly valid so t would make sense to me if
> they passed through NULL transparently.
> 
> No code can be depending on the fact they _don't_ do that now,
> so it seems like a safe change to me.
> 
> I'd actually be in favor of making the change, though perhaps I'm
> forgetting some reason why it would be a bad idea.
> 

It's certainly a safe change as far as not breaking any code, but I
know I've caught bugs before when the cast macros detected a NULL.

The change just doesn't seem very motivated to me - I've never found
myself wanting to use those macros on stuff that could be NULL.  How
often do we actually type "obj ? GTK_FOO (obj) : NULL"? It may be
worth thinking about why not. Perhaps when you know the derived type
of an object, you tend to also know whether it exists. Or maybe just
because most pointers are GtkWidget*, something that's changing with
GObject, and with GObject suddenly this will be an issue.

Havoc





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