The functions ecore_x_window_prop_card32_list_get, ecore_x_window_prop_xid_get, and ecore_x_window_prop_xid_list_get were buggy.

The original intention was that if the property is absent or not of extected type (or invalid window) they should return -1, otherwise they should return the number of elements in the property, 0 if none.

Unfortunately they all returned 0 if the property does not exist. Also, ecore_x_window_prop_xid_list_get retuned 0 if the property exists, has no elements, but has wrong type (should be -1).

These issues should be fixed now but this may cause problems in any code that relied on the incorrect behavior.



SVN revision: 41418
This commit is contained in:
Kim Woelders 2009-07-18 10:27:51 +00:00
parent a2b75fa66c
commit 1db0b28f52
1 changed files with 36 additions and 33 deletions

View File

@ -63,22 +63,26 @@ ecore_x_window_prop_card32_get(Ecore_X_Window win, Ecore_X_Atom atom,
int num;
prop_ret = NULL;
XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
XA_CARDINAL, &type_ret, &format_ret, &num_ret,
&bytes_after, &prop_ret);
if (prop_ret && type_ret == XA_CARDINAL && format_ret == 32)
{
if (num_ret < len)
len = num_ret;
if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
XA_CARDINAL, &type_ret, &format_ret, &num_ret,
&bytes_after, &prop_ret) != Success)
return -1;
for (i = 0; i < len; i++)
val[i] = ((unsigned long*)prop_ret)[i];
num = len;
if (type_ret != XA_CARDINAL || format_ret != 32)
{
num = -1;
}
else if (num_ret == 0 || !prop_ret)
{
num = 0;
}
else
{
num = -1;
if (num_ret < len)
len = num_ret;
for (i = 0; i < len; i++)
val[i] = ((unsigned long *)prop_ret)[i];
num = len;
}
if (prop_ret)
XFree(prop_ret);
@ -104,18 +108,22 @@ ecore_x_window_prop_card32_list_get(Ecore_X_Window win, Ecore_X_Atom atom,
unsigned int i, *val;
int num;
*plst = NULL;
prop_ret = NULL;
if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
XA_CARDINAL, &type_ret, &format_ret, &num_ret,
&bytes_after, &prop_ret) != Success)
return -1;
if (type_ret == None || num_ret == 0)
if (type_ret != XA_CARDINAL || format_ret != 32)
{
num = -1;
}
else if (num_ret == 0 || !prop_ret)
{
num = 0;
*plst = NULL;
}
else if (prop_ret && type_ret == XA_CARDINAL && format_ret == 32)
else
{
val = malloc(num_ret * sizeof(unsigned int));
for (i = 0; i < num_ret; i++)
@ -123,11 +131,6 @@ ecore_x_window_prop_card32_list_get(Ecore_X_Window win, Ecore_X_Atom atom,
num = num_ret;
*plst = val;
}
else
{
num = -1;
*plst = NULL;
}
if (prop_ret)
XFree(prop_ret);
@ -186,11 +189,15 @@ ecore_x_window_prop_xid_get(Ecore_X_Window win, Ecore_X_Atom atom,
&bytes_after, &prop_ret) != Success)
return -1;
if (type_ret == None)
if (type_ret != type || format_ret != 32)
{
num = -1;
}
else if (num_ret == 0 || !prop_ret)
{
num = 0;
}
else if (prop_ret && type_ret == type && format_ret == 32)
else
{
if (num_ret < len)
len = num_ret;
@ -198,10 +205,6 @@ ecore_x_window_prop_xid_get(Ecore_X_Window win, Ecore_X_Atom atom,
lst[i] = ((unsigned long *)prop_ret)[i];
num = len;
}
else
{
num = -1;
}
if (prop_ret)
XFree(prop_ret);
@ -235,21 +238,21 @@ ecore_x_window_prop_xid_list_get(Ecore_X_Window win, Ecore_X_Atom atom,
&bytes_after, &prop_ret) != Success)
return -1;
if (type_ret == None || num_ret == 0)
if (type_ret != type || format_ret != 32)
{
num = -1;
}
else if (num_ret == 0 || !prop_ret)
{
num = 0;
}
else if (prop_ret && type_ret == type && format_ret == 32)
else
{
alst = malloc(num_ret * sizeof(Ecore_X_ID));
for (i = 0; i < num_ret; i++)
alst[i] = ((unsigned long *)prop_ret)[i];
*val = alst;
num = num_ret;
}
else
{
num = -1;
*val = alst;
}
if (prop_ret)
XFree(prop_ret);