Ticket #1162 (closed defect: fixed)

Opened 8 years ago

Last modified 8 years ago

toResponse crashes the program if the response ID is 0 or less than -11.

Reported by: guest Owned by: somebody
Priority: normal Milestone:
Component: general (Gtk+, Glib) Version: 0.10.2
Keywords: Cc:


The code for toResponse reads as follows:

toResponse :: Integral a => a -> ResponseId? toResponse (-1) = ResponseNone? toResponse (-2) = ResponseReject? toResponse (-3) = ResponseAccept? toResponse (-4) = ResponseDeleteEvent? toResponse (-5) = ResponseOk? toResponse (-6) = ResponseCancel? toResponse (-7) = ResponseClose? toResponse (-8) = ResponseYes? toResponse (-9) = ResponseNo? toResponse (-10) = ResponseApply? toResponse (-11) = ResponseHelp? toResponse i | i > 0 = ResponseUser? $ fromIntegral i

If the repsonse ID is equal to zero or less than -11, this causes a

match failure and aborts the program. This happens, for instance, if you try to catch a response signal using afterResponse on a dialog that contains a button created with Glade whose response ID hasn't been set (the default is 0).

This bug was reported in the Debian Bug Tracking System: http://bugs.debian.org/522481 .

Change History

Changed 8 years ago by pgavin

  • status changed from new to closed
  • resolution set to fixed

I've fixed this to allow 0 as a ResponseId?. The Gtk+ docs seem to imply that user code shouldn't use negative values here, so I'm leaving that the way it is.

Changed 8 years ago by axel

  • version changed from 0.9.12 to 0.10.2

Ok, it seemed that I didn't fix this properly, thereby still breaking programs for 0. I've applied the patch from Marco which also allows for negative values to be returned. This shouldn't cause any harm.

Note: See TracTickets for help on using tickets.