princeamd pushed a commit to branch ecore-1.7.

commit 82fbdfcf1d945467702fd36cb421f3813d43d3ea
Author: Christopher Michael <[email protected]>
Date:   Tue Feb 5 08:53:18 2013 +0000

    Backport: f317906 :: Set number of returned modes early in the process. 
Let's be a bit pedantic here, if the number of returned modes is Zero, then 
just free resources and get out.
    
    Signed-off-by: Christopher Michael <[email protected]>
    
    SVN revision: 83617
    Signed-off-by: Deon Thomas <[email protected]>
---
 src/lib/ecore_x/xlib/ecore_x_randr.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/lib/ecore_x/xlib/ecore_x_randr.c 
b/src/lib/ecore_x/xlib/ecore_x_randr.c
index 9226b05..33c0ffc 100644
--- a/src/lib/ecore_x/xlib/ecore_x_randr.c
+++ b/src/lib/ecore_x/xlib/ecore_x_randr.c
@@ -639,6 +639,18 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root, int *num)
      {
         Ecore_X_Randr_Mode_Info **ret = NULL;
 
+        /* set the returned number of modes */
+        if (num) *num = res->nmode;
+
+        /* if we did not get any modes from X, then cleanup and return */
+        if (res->nmode == 0)
+          {
+             /* free the resources */
+             XRRFreeScreenResources(res);
+
+             return NULL;
+          }
+
         /* try to allocate space for our return variable */
         if ((ret = (Ecore_X_Randr_Mode_Info **)
              malloc(res->nmode * sizeof(Ecore_X_Randr_Mode_Info *))))
@@ -682,9 +694,6 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root, int *num)
                }
           }
 
-        /* set the returned number of modes */
-        if ((ret) && (num)) *num = res->nmode;
-
         /* free the resources */
         XRRFreeScreenResources(res);
 

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to