[Spice-commits] 2 commits - vdagent/display_configuration.cpp vdagent/display_configuration.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Fri Sep 2 15:56:42 UTC 2016


 vdagent/display_configuration.cpp |   23 +++++++++++------------
 vdagent/display_configuration.h   |    2 +-
 2 files changed, 12 insertions(+), 13 deletions(-)

New commits:
commit debf1fe98148ddf1a44735449512bd4229b53213
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Sep 1 15:57:16 2016 +0100

    Make CCD::load_api throw exception on its own
    
    Avoid to use two different ways to handle errors.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Sameeh Jubran <sameeh at daynix.com>

diff --git a/vdagent/display_configuration.cpp b/vdagent/display_configuration.cpp
index 29a1030..6e7624b 100644
--- a/vdagent/display_configuration.cpp
+++ b/vdagent/display_configuration.cpp
@@ -691,12 +691,8 @@ CCD::CCD()
     ,_primary_detached(false)
     ,_path_state(PATH_UPDATED)
 {
-    if (load_api()) {
-        get_config_buffers();
-    }
-    else {
-        throw std::exception();
-    }
+    load_api();
+    get_config_buffers();
 }
 
 CCD::~CCD()
@@ -801,14 +797,13 @@ void CCD::debug_print_config(const char* prefix)
     }
 }
 
-bool CCD::load_api()
+void CCD::load_api()
 {
     HMODULE hModule = GetModuleHandle(L"user32.dll");
-    if(!hModule) {
-        return false;
+    if (!hModule) {
+        throw std::exception();
     }
 
-    bool bFound_all(false);
     do {
         if (!(_pfnGetDeviceInfo = (PDISPLAYCONFIG_GETDEVICEINFO)
             GetProcAddress(hModule, "DisplayConfigGetDeviceInfo"))) {
@@ -829,11 +824,11 @@ bool CCD::load_api()
             GetProcAddress(hModule, "SetDisplayConfig"))) {
             break;
         }
-        bFound_all = true;
+        return;
     }
     while(0);
 
-    return bFound_all;
+    throw std::exception();
 }
 
 bool CCD::get_config_buffers()
diff --git a/vdagent/display_configuration.h b/vdagent/display_configuration.h
index 7abf526..ef4f989 100644
--- a/vdagent/display_configuration.h
+++ b/vdagent/display_configuration.h
@@ -67,7 +67,7 @@ public:
     void debug_print_config(const char* prefix = NULL);
 
 private:
-    bool load_api();
+    void load_api();
     bool get_config_buffers();
     void free_config_buffers();
     bool is_device_path(LPCTSTR device_name, DISPLAYCONFIG_PATH_INFO* path);
commit b24a935335cf72de998a4fa8d02bf1e44d06fd28
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Sep 1 12:53:04 2016 +0100

    Fails CCD initialisation if get_config_buffers detect WDDM is not present
    
    There's no point continuing without WDDM as CCD cannot work without it.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Sameeh Jubran <sameeh at daynix.com>

diff --git a/vdagent/display_configuration.cpp b/vdagent/display_configuration.cpp
index 2fa7089..29a1030 100644
--- a/vdagent/display_configuration.cpp
+++ b/vdagent/display_configuration.cpp
@@ -843,6 +843,10 @@ bool CCD::get_config_buffers()
     LONG error(ERROR_SUCCESS);
     error = _pfnGetDisplayConfigBufferSizes(QDC_ALL_PATHS, &_numPathElements,
                                             &_numModeElements);
+    if (error == ERROR_NOT_SUPPORTED) {
+        vd_printf("GetDisplayConfigBufferSizes failed, missing WDDM");
+        throw std::exception();
+    }
     if (error) {
         vd_printf("GetDisplayConfigBufferSizes failed with 0x%lx", error);
         return false;


More information about the Spice-commits mailing list