Index: trunk/src/3rdparty/os2/xsystray/apilib/xsystray.c
===================================================================
--- trunk/src/3rdparty/os2/xsystray/apilib/xsystray.c	(revision 950)
+++ trunk/src/3rdparty/os2/xsystray/apilib/xsystray.c	(revision 951)
@@ -316,5 +316,5 @@
 
     // give all processes temporary access to hIcon
-    brc = WinSetPointerOwner(hIcon, 0, FALSE);
+    brc = hIcon != NULLHANDLE ? WinSetPointerOwner(hIcon, 0, FALSE) : TRUE;
     if (brc)
     {
@@ -340,6 +340,9 @@
 
         // revoke temporary access to hIcon
-        DosGetInfoBlocks(NULL, &ppib);
-        WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
+        if (hIcon != NULLHANDLE)
+        {
+            DosGetInfoBlocks(NULL, &ppib);
+            WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
+        }
     }
 
@@ -402,5 +405,5 @@
 
     // give all processes temporary access to hIcon
-    brc = WinSetPointerOwner(hIcon, 0, FALSE);
+    brc = hIcon != NULLHANDLE ? WinSetPointerOwner(hIcon, 0, FALSE) : TRUE;
     if (brc)
     {
@@ -414,6 +417,9 @@
 
         // revoke temporary access to hIcon
-        DosGetInfoBlocks(NULL, &ppib);
-        WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
+        if (hIcon != NULLHANDLE)
+        {
+            DosGetInfoBlocks(NULL, &ppib);
+            WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
+        }
     }
 
Index: trunk/src/3rdparty/os2/xsystray/plugin/w_xsystray.c
===================================================================
--- trunk/src/3rdparty/os2/xsystray/plugin/w_xsystray.c	(revision 950)
+++ trunk/src/3rdparty/os2/xsystray/plugin/w_xsystray.c	(revision 951)
@@ -828,5 +828,8 @@
                 break;
 
-            DrawPointer(hps, x, y, pSysTrayData->pIcons[i].hIcon, DP_MINI);
+            // just leave an empty box if the icon is NULL, this is what
+            // Windows and Linux tray widgets do
+            if (pSysTrayData->pIcons[i].hIcon != NULLHANDLE)
+                DrawPointer(hps, x, y, pSysTrayData->pIcons[i].hIcon, DP_MINI);
             x += lIconStep;
         }
@@ -1210,10 +1213,13 @@
             // make a private copy of the provided icon (it will get lost after
             // we return from this message)
-            brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
-            if (!brc)
-                break;
-            hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
-            if (hIcon == NULLHANDLE)
-                break;
+            if (pCtlData->u.icon.hIcon != NULLHANDLE)
+            {
+                brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
+                if (!brc)
+                    break;
+                hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
+                if (hIcon == NULLHANDLE)
+                    break;
+            }
 
             pData = FindIconData(pSysTrayData, pCtlData->hwndSender,
@@ -1231,5 +1237,6 @@
                     if (!pData->pszToolTip)
                     {
-                        WinDestroyPointer(hIcon);
+                        if (hIcon != NULLHANDLE)
+                            WinDestroyPointer(hIcon);
                         break;
                     }
@@ -1251,5 +1258,6 @@
 
                 // now update the icon
-                WinDestroyPointer(pData->hIcon);
+                if (pData->hIcon != NULLHANDLE)
+                    WinDestroyPointer(pData->hIcon);
                 pData->hIcon = hIcon;
                 pData->ulMsgId = pCtlData->u.icon.ulMsgId;
@@ -1276,5 +1284,6 @@
                     if (pNewIcons == NULL)
                     {
-                        WinDestroyPointer(hIcon);
+                        if (hIcon != NULLHANDLE)
+                            WinDestroyPointer(hIcon);
                         break;
                     }
@@ -1299,5 +1308,6 @@
                     if (!pData->pszToolTip)
                     {
-                        WinDestroyPointer(hIcon);
+                        if (hIcon != NULLHANDLE)
+                            WinDestroyPointer(hIcon);
                         break;
                     }
@@ -1328,10 +1338,13 @@
             // make a private copy of the provided icon (it will get lost after
             // we return from this message)
-            brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
-            if (!brc)
-                break;
-            hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
-            if (hIcon == NULLHANDLE)
-                break;
+            if (pCtlData->u.icon.hIcon != NULLHANDLE)
+            {
+                brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
+                if (!brc)
+                    break;
+                hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
+                if (hIcon == NULLHANDLE)
+                    break;
+            }
 
             pData = FindIconData(pSysTrayData, pCtlData->hwndSender,
@@ -1341,5 +1354,6 @@
                 LOGF((" Replacing with hIcon %x\n", hIcon));
 
-                WinDestroyPointer(pData->hIcon);
+                if (pData->hIcon != NULLHANDLE)
+                    WinDestroyPointer(pData->hIcon);
                 pData->hIcon = hIcon;
                 pData->ulMsgId = pCtlData->u.icon.ulMsgId;
