PrintDlgEx [4/7]: Implement hDevMode and hDevNames on output.

Juan Lang juan.lang at gmail.com
Thu Sep 18 09:59:36 CDT 2008


Hi Gal,

+            WORD locks;
+            if ((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
+                WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
+                while(locks--) {
+                    GlobalUnlock(lppd->hDevMode);
+                    TRACE("Now got %d locks\n", locks);

This looks funny.  The loop may have a race condition if someone else
is locking/unlocking it.  The following would be simpler, and more
importantly, more likely to be correct:

    WORD locks;
    while ((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
        GlobalUnlock(lppd->hDevMode);
        TRACE("Now got %d locks\n", locks);
    }

The same comment applies to unlocking hDevNames.
--Juan



More information about the wine-devel mailing list