On 02/26/2015 03:38 AM, Jose Fonseca wrote:
We were never processing the WM_QUIT message, as GetMessage returns 0 in
that case, and we were falling in an infinite loop.

We also never see WM_CLOSE messages when pressing Alt-F4 or closing the
window via the taskbar.  We do however see WM_SYSCOMMAND::SC_CLOSE mesage.
So handle that instead.

With this change we always quit properly, regardless of the method
(Escape/Alt-F4/Close window).
---
  .../piglit-framework-gl/piglit_wgl_framework.c     | 23 ++++++++++++++++++----
  1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/tests/util/piglit-framework-gl/piglit_wgl_framework.c 
b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
index 51fdf1f..e0474d8 100644
--- a/tests/util/piglit-framework-gl/piglit_wgl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
@@ -36,9 +36,14 @@ process_next_event(struct piglit_winsys_framework *winsys_fw)
        BOOL bRet;
        MSG msg;

-       bRet = GetMessage(&msg, NULL, 0, 0 );
-       if (bRet <= 0) {
-               return;
+       bRet = GetMessage(&msg, NULL, 0, 0);
+       /* bRet will be negative on error, zero on WM_QUIT, positive for other 
messages */
+       if (bRet < 0) {
+               exit(EXIT_FAILURE);
+       }
+
+       if (0) {
+               fprintf(stderr, "message = 0x%04x, wParam = 0x%04x\n", 
msg.message, msg.wParam);
        }

        switch (msg.message) {
@@ -62,10 +67,20 @@ process_next_event(struct piglit_winsys_framework 
*winsys_fw)
                }
                winsys_fw->need_redisplay = true;
                break;
+       case WM_SYSCOMMAND:
+               switch (msg.wParam) {
+               case SC_CLOSE:
+                       PostQuitMessage(EXIT_SUCCESS);
+                       break;
+               }

Unless you anticipate adding more switch cases someday, I'd just use a conditional there.


+               break;
        case WM_CLOSE:
+               /* XXX: we never see this message here in practice, only 
WM_SYSCOMMAND::SC_CLOSE above */
+               PostQuitMessage(EXIT_SUCCESS);
+               break;
        case WM_QUIT:
                /* TODO: cleanup/teardown things */
-               exit(0);
+               exit(msg.wParam);
        default:
                break;
        }


For both: Reviewed-by: Brian Paul <bri...@vmware.com>


_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to