Browse Source

Avoid a crash when a tray without a menu is clicked on Windows.

Petar Popovic 2 months ago
parent
commit
6f098a920e
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/tray/windows/SDL_tray.c

+ 4 - 1
src/tray/windows/SDL_tray.c

@@ -115,7 +115,10 @@ LRESULT CALLBACK TrayWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
         case WM_TRAYICON:
             if (LOWORD(lParam) == WM_CONTEXTMENU || LOWORD(lParam) == WM_LBUTTONUP) {
                 SetForegroundWindow(hwnd);
-                TrackPopupMenu(tray->menu->hMenu, TPM_BOTTOMALIGN | TPM_RIGHTALIGN, GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam), 0, hwnd, NULL);
+                
+                if (tray->menu) {
+                    TrackPopupMenu(tray->menu->hMenu, TPM_BOTTOMALIGN | TPM_RIGHTALIGN, GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam), 0, hwnd, NULL);
+                }
             }
             break;