Skip to content

Commit

Permalink
EnumClipboardFormats returning 0 is not an error (#4452)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed May 9, 2012
1 parent 0d58704 commit 6c035c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Graphics/Win32/GDI/Clip.hsc
Expand Up @@ -17,6 +17,7 @@

module Graphics.Win32.GDI.Clip where

import Control.Monad
import Graphics.Win32.GDI.Types
import System.Win32.Types

Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions 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')
1 change: 1 addition & 0 deletions tests/all.T
Expand Up @@ -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'])

0 comments on commit 6c035c1

Please sign in to comment.