[Spice-devel] [PATCH 2/4] client: menu: make RedWindow::set_menu() return an error-code (#758260)

Uri Lublin uril at redhat.com
Tue Dec 20 08:52:42 PST 2011


RedWindow::set_menu() can fail (on Windows when in fullscreen mode).
For Windows spice-client, when in fullscreen mode, the system-menu
is NULL.

Returns 0 upon success, non-0 (currently only -1) upon failure.
---
 client/red_window.h           |    2 +-
 client/windows/red_window.cpp |   14 +++++++++++---
 client/x11/red_window.cpp     |    3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/client/red_window.h b/client/red_window.h
index 3dea26b..82353aa 100644
--- a/client/red_window.h
+++ b/client/red_window.h
@@ -70,7 +70,7 @@ public:
     void release_mouse();
     void start_key_interception();
     void stop_key_interception();
-    void set_menu(Menu* menu);
+    int set_menu(Menu* menu);
 
 #ifdef USE_OPENGL
     void untouch_context();
diff --git a/client/windows/red_window.cpp b/client/windows/red_window.cpp
index 1345e91..981fe9a 100644
--- a/client/windows/red_window.cpp
+++ b/client/windows/red_window.cpp
@@ -1064,18 +1064,26 @@ void RedWindow_p::release_menu(Menu* menu)
     }
 }
 
-void RedWindow::set_menu(Menu* menu)
+int RedWindow::set_menu(Menu* menu)
 {
     release_menu(_menu);
     _menu = NULL;
 
     if (!menu) {
-        return;
+        return 0;
     }
-    _menu = menu->ref();
+
     _sys_menu = GetSystemMenu(_win, FALSE);
+    if (! _sys_menu) {
+        return -1;
+    }
+
+    _menu = menu->ref();
+
     insert_separator(_sys_menu);
     insert_menu(_menu, _sys_menu, _commands_map);
+
+    return 0;
 }
 
 static LRESULT CALLBACK MessageFilterProc(int nCode, WPARAM wParam, LPARAM lParam)
diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 0c95925..2d179f8 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -2218,8 +2218,9 @@ void RedWindow::on_pointer_leave()
     }
 }
 
-void RedWindow::set_menu(Menu* menu)
+int RedWindow::set_menu(Menu* menu)
 {
+    return 0;
 }
 
 void RedWindow::init()
-- 
1.7.1



More information about the Spice-devel mailing list