[bug] error in unmarshalMouseButton

Hi, I'm developing a mouse-driven user interface using HOpenGL/GLUT. However, it sometimes crashes if I'm too clumsy on my laptop's trackpad: $ ./gulci gulci: unmarshalMouseButton: illegal value 5 $ ./gulci gulci: unmarshalMouseButton: illegal value 6 The offending code calls error: --8<-- unmarshalMouseButton :: CInt -> MouseButton unmarshalMouseButton x | x == glut_LEFT_BUTTON = LeftButton | x == glut_MIDDLE_BUTTON = MiddleButton | x == glut_RIGHT_BUTTON = RightButton | x == glut_WHEEL_UP = WheelUp | x == glut_WHEEL_DOWN = WheelDown | otherwise = error ("unmarshalMouseButton: illegal value " ++ show x) --8<-- http://www.haskell.org/ghc/dist/current/docs/libraries/GLUT/src/Graphics-UI-... Suggested fix: modify the MouseButton type to have an additional constructor, eg: data MouseButton = ... | OtherMouseButton CInt and handle that case in the obvious way in the (un)marshal code (and suitably adjust any other code that pattern matches on MouseButton) BTW, I noticed I'm not the first to suffer from this crash issue, see for example #haskell IRC log from 2008-05-16. Claude -- http://claudiusmaximus.goto10.org

Claude Heiland-Allen wrote:
Suggested fix:
diff attached. Claude -- http://claudiusmaximus.goto10.org

Am Dienstag, 16. Juni 2009 14:23:24 schrieb Claude Heiland-Allen:
Claude Heiland-Allen wrote:
Suggested fix:
diff attached.
I'm fine with the addition, just one minor notice: The package versioning policy (http://www.haskell.org/haskellwiki/Package_versioning_policy) tells us that we must bump at least the minor version number of the GLUT package from 2.1.2.1 to 2.1.3.0. The PVP could even be interpreted in such a way that we must bump the major version number, i.e. use 2.2.0.0, but it is a bit unclear about what to do when only a new alternative is added to an already existing algebraic data type. On the one hand, a data type is changed, but on the other hand one basically simply introduces a new binding (the new constructor). I'm not sure what the consensus is in such a case. Your patch will be in the next GLUT release. Thanks, S.
participants (2)
-
Claude Heiland-Allen
-
Sven Panne