Ticket #4452 (closed bug: fixed)
Graphics.Win32.GDI.Clip.enumClipboardFormats fails on success.
| Reported by: | fryguybob | Owned by: | pcapriotti |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.6.1 |
| Component: | libraries (other) | Version: | 6.12.3 |
| Keywords: | Win32, Clipboard | Cc: | |
| Operating System: | Windows | Architecture: | Unknown/Multiple |
| Type of failure: | Incorrect result at runtime | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description (last modified by igloo) (diff)
According to the documentation for the Win32 EnumClipboardFormats function:
http://msdn.microsoft.com/en-us/library/ms649038(VS.85).aspx
A return value of zero is only an error if a subsequent call to GetLastError does not return ERROR_SUCCESS. The following code is what I would expect:
errorWinNotErrorSuccess :: (Num a) => String -> IO a errorWinNotErrorSuccess fn_name = do err_code <- getLastError if err_code == 0 then return 0 else failWith fn_name err_code failIfZeroAndNotErrorSuccess :: Num a => String -> IO a -> IO a failIfZeroAndNotErrorSuccess wh act = do v <- act if v == 0 then errorWinNotErrorSuccess wh else return v enumClipboardFormats :: ClipboardFormat -> IO ClipboardFormat enumClipboardFormats format = failIfZeroAndNotErrorSuccess "EnumClipboardFormats" $ c_EnumClipboardFormats format
Instead of the current:
enumClipboardFormats :: ClipboardFormat -> IO ClipboardFormat enumClipboardFormats format = failIfZero "EnumClipboardFormats" $ c_EnumClipboardFormats format
Change History
Note: See
TracTickets for help on using
tickets.
