Fixed getWindowProperty(). It wasn't catching all failure

cases correctly.
This commit is contained in:
crs 2003-03-21 19:13:15 +00:00
parent a5633b1971
commit 995c9547cf
1 changed files with 7 additions and 6 deletions

View File

@ -35,7 +35,7 @@ CXWindowsUtil::getWindowProperty(Display* display, Window window,
CXWindowsUtil::CErrorLock lock(display); CXWindowsUtil::CErrorLock lock(display);
// read the property // read the property
int result = Success; bool okay = true;
const long length = XMaxRequestSize(display); const long length = XMaxRequestSize(display);
long offset = 0; long offset = 0;
unsigned long bytesLeft = 1; unsigned long bytesLeft = 1;
@ -43,12 +43,13 @@ CXWindowsUtil::getWindowProperty(Display* display, Window window,
// get more data // get more data
unsigned long numItems; unsigned long numItems;
unsigned char* rawData; unsigned char* rawData;
result = XGetWindowProperty(display, window, property, if (XGetWindowProperty(display, window, property,
offset, length, False, AnyPropertyType, offset, length, False, AnyPropertyType,
&actualType, &actualDatumSize, &actualType, &actualDatumSize,
&numItems, &bytesLeft, &rawData); &numItems, &bytesLeft, &rawData) != Success ||
if (result != Success || actualType == None || actualDatumSize == 0) { actualType == None || actualDatumSize == 0) {
// failed // failed
okay = false;
break; break;
} }
@ -98,12 +99,12 @@ CXWindowsUtil::getWindowProperty(Display* display, Window window,
*format = static_cast<SInt32>(actualDatumSize); *format = static_cast<SInt32>(actualDatumSize);
} }
if (result == Success) { if (okay) {
LOG((CLOG_DEBUG2 "read property %d on window 0x%08x: bytes=%d", property, window, (data == NULL) ? 0 : data->size())); LOG((CLOG_DEBUG2 "read property %d on window 0x%08x: bytes=%d", property, window, (data == NULL) ? 0 : data->size()));
return true; return true;
} }
else { else {
LOG((CLOG_DEBUG1 "can't read property %d on window 0x%08x", property, window)); LOG((CLOG_DEBUG2 "can't read property %d on window 0x%08x", property, window));
return false; return false;
} }
} }