Opened 6 years ago

Closed 5 years ago

#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 Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

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 (8)

comment:1 Changed 6 years ago by igloo

Description: modified (diff)

comment:2 Changed 6 years ago by igloo

Milestone: 7.0.2
Status: newpatch

Thanks for the report and suggestion!

comment:3 Changed 6 years ago by igloo

Milestone: 7.0.27.2.1

comment:4 Changed 5 years ago by igloo

Owner: set to bos

comment:5 Changed 5 years ago by igloo

Milestone: 7.2.17.4.1

comment:6 Changed 5 years ago by igloo

Milestone: 7.4.17.6.1

comment:7 Changed 5 years ago by simonpj

difficulty: Unknown
Owner: changed from bos to pcapriotti

comment:8 Changed 5 years ago by pcapriotti

Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.