Opened 3 years ago

Closed 2 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 Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

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 3 years ago by igloo

  • Description modified (diff)

comment:2 Changed 3 years ago by igloo

  • Milestone set to 7.0.2
  • Status changed from new to patch

Thanks for the report and suggestion!

comment:3 Changed 3 years ago by igloo

  • Milestone changed from 7.0.2 to 7.2.1

comment:4 Changed 3 years ago by igloo

  • Owner set to bos

comment:5 Changed 3 years ago by igloo

  • Milestone changed from 7.2.1 to 7.4.1

comment:6 Changed 2 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1

comment:7 Changed 2 years ago by simonpj

  • Difficulty set to Unknown
  • Owner changed from bos to pcapriotti

comment:8 Changed 2 years ago by pcapriotti

  • Resolution set to fixed
  • Status changed from patch to closed
Note: See TracTickets for help on using tickets.