New patch attached. On Sat, Dec 20, 2008 at 3:13 AM, Hans Breuer <hans breuer org> wrote:
Sorry, I don't see how adding g_return_if_fail() should ensure anything.
Ok. My mistake. What I want is a warning followed by a return. Updated the patch accordingly. The new patch also fixes an existing use of g_return_if_fail() in lib/object_defaults.c Note the use of g_warn_if_reached() instead of g_warning(), since the former provides the location in the code ... an actual warning text is not important since the developer will examine the code anyway.
Also your patch would partially revert revision 3876 (for the above mentioned case): 2008-01-10 Hans Breuer <hans breuer org> * app/create_object.c(create_object_button_release) : don't crash on tool->obj being NULL, just do nothing than.
I think you meant revision 3716 (from bzr blame). That's exactly the crash that I saw, but in a different place, as describe below.
I actually encountered this because of another problem with the DATADIR setting. I suppose the CreateObjectTool rarely fails in normal environments.It rarely does but still should not crash.
It does crash in create_object_button_press(), in app/create_object.c ... the call to dia_object_default_create() can possibly return a NULL, which is not checked. The pointer check intended in 3716 checks for this is in _button_release(), but it should also be checked in _button_press() and _motion(). It is sufficient to place the related warning only in _button_press(). Sameer. -- http://www.it.iitb.ac.in/~sameerds/
Attachment:
create_object.patch
Description: Text Data