[haiku-bugs] Re: [Haiku] #10733: [BOptionPopUp] can crash when containing a SeparatorItem

  • From: "ttcoder" <trac@xxxxxxxxxxxx>
  • Date: Wed, 02 Apr 2014 13:28:55 -0000

#10733: [BOptionPopUp] can crash when containing a SeparatorItem
----------------------------------+----------------------------
   Reporter:  ttcoder             |      Owner:  axeld
       Type:  bug                 |     Status:  new
   Priority:  normal              |  Milestone:  R1
  Component:  Kits/Interface Kit  |    Version:  R1/Development
 Resolution:                      |   Keywords:
 Blocked By:                      |   Blocking:
Has a Patch:  0                   |   Platform:  All
----------------------------------+----------------------------

Comment (by ttcoder):

 That would fix the crash in my case just as well indeed.

 One might want to update the BeBook (if necessary) in that case, to
 mention that GetOptionAt() would return `true` not only for menu items
 that were created as actual "options" (with the AddOptionAt() method) but
 also for custom-made menu items and for separator items. Thus it would
 rarely if ever return 'false'. Probably makes sense. I'm happy either
 way.. With one caveat:

 Beware that SelectOptionFor()..

 http://cgit.haiku-
 os.org/haiku/tree/src/kits/interface/OptionControl.cpp#n95

 ... does not initialize its "int32 optionValue" parameter (that's an awful
 practice that plagues the whole Haiku source tree, but that's a discussion
 for another time and place..) when passing it to GetOptionAt(), so one
 would need to either 1) initialize that variable, knowing it won't be
 affected in GetOptionAt(), or 2) change GetOptionAt() so that it sets it
 to 0 (or -1) if it cannot find the Message() field in the menu item,
 otherwise we get the dreaded "undefined behavior"..!

--
Ticket URL: <https://dev.haiku-os.org/ticket/10733#comment:3>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: