lv2 / pugl

A minimal portable API for embeddable GUIs
https://gitlab.com/lv2/pugl/
ISC License
174 stars 34 forks source link

EndPaint / BeginPaint on windows #103

Closed swesterfeld closed 1 year ago

swesterfeld commented 1 year ago

I am getting a warning about the PAINTSTRUCT argument for EndPaint in my version of pugl (which has diverged from yours a bit), for this

https://github.com/lv2/pugl/blob/3e6504247e5eb05fb9e326f8550daa5e2a18737a/src/win_gl.c#L279

pugl_win.cpp: In function 'void puglLeaveContext(PuglView*, bool)':
pugl_win.cpp:112:17: warning: 'ps' may be used uninitialized [-Wmaybe-uninitialized]
  112 |         EndPaint(view->impl->hwnd, &ps);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /mxe/usr/x86_64-w64-mingw32.static/include/windows.h:72,
                 from pugl_win.cpp:21:
/mxe/usr/x86_64-w64-mingw32.static/include/winuser.h:3550:29: note: by argument 2 of type 'const PAINTSTRUCT*' {aka 'const tagPAINTSTRUCT*'} to 'WINBOOL EndPaint(HWND, const PAINTSTRUCT*)' declared here
 3550 |   WINUSERAPI WINBOOL WINAPI EndPaint(HWND hWnd,CONST PAINTSTRUCT *lpPaint);
      |                             ^~~~~~~~
pugl_win.cpp:111:21: note: 'ps' declared here
  111 |         PAINTSTRUCT ps;
      |                     ^~

As far as I understand the documentation

pugl should keep the PAINTSTRUCT value generated by BeginPaint() here and pass it to EndPaint() later on.

drobilla commented 1 year ago

Hm, yep. Fixed in 1e75509, thanks. I also factored this out so it happens in exactly one place in ad8ecdf.