Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

EnumClipboardFormats returning 0 is not an error (#4452)

  • Loading branch information...
commit 6c035c1fb7cb0bba64cdea3a3e1a84c19ef4cd18 1 parent 0d58704
@pcapriotti pcapriotti authored
Showing with 20 additions and 2 deletions.
  1. +6 −2 Graphics/Win32/GDI/Clip.hsc
  2. +13 −0 tests/T4452.hs
  3. +1 −0  tests/all.T
View
8 Graphics/Win32/GDI/Clip.hsc
@@ -17,6 +17,7 @@
module Graphics.Win32.GDI.Clip where
+import Control.Monad
import Graphics.Win32.GDI.Types
import System.Win32.Types
@@ -75,8 +76,11 @@ foreign import stdcall unsafe "windows.h EmptyClipboard"
-- original also tested GetLastError() != NO_ERROR
enumClipboardFormats :: ClipboardFormat -> IO ClipboardFormat
-enumClipboardFormats format =
- failIfZero "EnumClipboardFormats" $ c_EnumClipboardFormats format
+enumClipboardFormats format = do
+ format' <- c_EnumClipboardFormats format
+ when (format' == 0) $
+ failUnlessSuccess "EnumClipboardFormats" getLastError
+ return format'
foreign import stdcall unsafe "windows.h EnumClipboardFormats"
c_EnumClipboardFormats :: ClipboardFormat -> IO ClipboardFormat
View
13 tests/T4452.hs
@@ -0,0 +1,13 @@
+module Main where
+
+import Control.Monad
+import Foreign.Ptr
+import Graphics.Win32.GDI.Clip
+
+main = do
+ openClipboard nullPtr
+ go 0
+ where
+ go n = do
+ n' <- enumClipboardFormats n
+ unless (n == 0) (go n')
View
1  tests/all.T
@@ -5,3 +5,4 @@ test('registry001', normal, compile_and_run, [''])
test('helloworld', skip, compile_and_run, ['-package lang -package win32'])
test('lasterror', normal, compile_and_run, ['-package Win32'])
+test('T4452', normal, compile_and_run, ['-package Win32'])
Please sign in to comment.
Something went wrong with that request. Please try again.