CXWindowsUtil::CErrorLock wasn't XSync()'ing the display before
installing and uninstalling the new error handler, causing errors before the lock to be caught and errors during the lock to not be caught. had to add Display* as argument to c'tor.
This commit is contained in:
parent
504bfa2def
commit
95a1ce8798
|
@ -800,7 +800,7 @@ CXWindowsClipboard::insertReply(CReply* reply)
|
||||||
if (newWindow) {
|
if (newWindow) {
|
||||||
// note errors while we adjust event masks
|
// note errors while we adjust event masks
|
||||||
bool error = false;
|
bool error = false;
|
||||||
CXWindowsUtil::CErrorLock lock(&error);
|
CXWindowsUtil::CErrorLock lock(m_display, &error);
|
||||||
|
|
||||||
// get and save the current event mask
|
// get and save the current event mask
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
|
@ -852,7 +852,7 @@ CXWindowsClipboard::pushReplies(CReplyMap::iterator mapIndex,
|
||||||
// if there are no more replies in the list then remove the list
|
// if there are no more replies in the list then remove the list
|
||||||
// and stop watching the requestor for events.
|
// and stop watching the requestor for events.
|
||||||
if (replies.empty()) {
|
if (replies.empty()) {
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
Window requestor = mapIndex->first;
|
Window requestor = mapIndex->first;
|
||||||
XSelectInput(m_display, requestor, m_eventMasks[requestor]);
|
XSelectInput(m_display, requestor, m_eventMasks[requestor]);
|
||||||
m_replies.erase(mapIndex);
|
m_replies.erase(mapIndex);
|
||||||
|
@ -926,7 +926,7 @@ CXWindowsClipboard::sendReply(CReply* reply)
|
||||||
log((CLOG_DEBUG1 "clipboard: sending failure to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
log((CLOG_DEBUG1 "clipboard: sending failure to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
||||||
reply->m_done = true;
|
reply->m_done = true;
|
||||||
if (reply->m_property != None) {
|
if (reply->m_property != None) {
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
XDeleteProperty(m_display, reply->m_requestor, reply->m_property);
|
XDeleteProperty(m_display, reply->m_requestor, reply->m_property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1016,7 +1016,7 @@ CXWindowsClipboard::sendNotify(Window requestor,
|
||||||
event.xselection.target = target;
|
event.xselection.target = target;
|
||||||
event.xselection.property = property;
|
event.xselection.property = property;
|
||||||
event.xselection.time = time;
|
event.xselection.time = time;
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
XSendEvent(m_display, requestor, False, 0, &event);
|
XSendEvent(m_display, requestor, False, 0, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(Display* display) :
|
||||||
// watch top-level windows for changes
|
// watch top-level windows for changes
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
CXWindowsUtil::CErrorLock lock(&error);
|
CXWindowsUtil::CErrorLock lock(m_display, &error);
|
||||||
Window root = DefaultRootWindow(m_display);
|
Window root = DefaultRootWindow(m_display);
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
XGetWindowAttributes(m_display, root, &attr);
|
XGetWindowAttributes(m_display, root, &attr);
|
||||||
|
@ -46,7 +46,7 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(Display* display) :
|
||||||
CXWindowsScreenSaver::~CXWindowsScreenSaver()
|
CXWindowsScreenSaver::~CXWindowsScreenSaver()
|
||||||
{
|
{
|
||||||
// stop watching root for events
|
// stop watching root for events
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
Window root = DefaultRootWindow(m_display);
|
Window root = DefaultRootWindow(m_display);
|
||||||
XSelectInput(m_display, root, m_rootEventMask);
|
XSelectInput(m_display, root, m_rootEventMask);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ CXWindowsScreenSaver::sendNotify(bool activated)
|
||||||
event.xclient.data.l[3] = 0;
|
event.xclient.data.l[3] = 0;
|
||||||
event.xclient.data.l[4] = 0;
|
event.xclient.data.l[4] = 0;
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
XSendEvent(m_display, m_notify, False, 0, &event);
|
XSendEvent(m_display, m_notify, False, 0, &event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ CXWindowsScreenSaver::updateXScreenSaver()
|
||||||
}
|
}
|
||||||
|
|
||||||
// find top-level window with m_atomScreenSaverVersion string property
|
// find top-level window with m_atomScreenSaverVersion string property
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
Window root = DefaultRootWindow(m_display);
|
Window root = DefaultRootWindow(m_display);
|
||||||
Window rw, pw, *cw;
|
Window rw, pw, *cw;
|
||||||
unsigned int nc;
|
unsigned int nc;
|
||||||
|
@ -224,7 +224,7 @@ CXWindowsScreenSaver::updateXScreenSaver()
|
||||||
// see if xscreensaver is active
|
// see if xscreensaver is active
|
||||||
if (m_xscreensaver != None) {
|
if (m_xscreensaver != None) {
|
||||||
bool error = false;
|
bool error = false;
|
||||||
CXWindowsUtil::CErrorLock lock(&error);
|
CXWindowsUtil::CErrorLock lock(m_display, &error);
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
XGetWindowAttributes(m_display, m_xscreensaver, &attr);
|
XGetWindowAttributes(m_display, m_xscreensaver, &attr);
|
||||||
setXScreenSaver(!error && attr.map_state != IsUnmapped);
|
setXScreenSaver(!error && attr.map_state != IsUnmapped);
|
||||||
|
@ -250,6 +250,6 @@ CXWindowsScreenSaver::sendXScreenSaverCommand(
|
||||||
event.xclient.data.l[3] = 0;
|
event.xclient.data.l[3] = 0;
|
||||||
event.xclient.data.l[4] = 0;
|
event.xclient.data.l[4] = 0;
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
XSendEvent(m_display, m_xscreensaver, False, 0, &event);
|
XSendEvent(m_display, m_xscreensaver, False, 0, &event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ CXWindowsUtil::getWindowProperty(Display* display, Window window,
|
||||||
int actualDatumSize;
|
int actualDatumSize;
|
||||||
|
|
||||||
// ignore errors. XGetWindowProperty() will report failure.
|
// ignore errors. XGetWindowProperty() will report failure.
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(display);
|
||||||
|
|
||||||
// read the property
|
// read the property
|
||||||
const long length = XMaxRequestSize(display);
|
const long length = XMaxRequestSize(display);
|
||||||
|
@ -93,7 +93,7 @@ CXWindowsUtil::setWindowProperty(Display* display, Window window,
|
||||||
|
|
||||||
// save errors
|
// save errors
|
||||||
bool error = false;
|
bool error = false;
|
||||||
CXWindowsUtil::CErrorLock lock(&error);
|
CXWindowsUtil::CErrorLock lock(display, &error);
|
||||||
|
|
||||||
// how much data to send in first chunk?
|
// how much data to send in first chunk?
|
||||||
UInt32 chunkSize = size;
|
UInt32 chunkSize = size;
|
||||||
|
@ -179,23 +179,31 @@ CXWindowsUtil::propertyNotifyPredicate(Display*, XEvent* xevent, XPointer arg)
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock* CXWindowsUtil::CErrorLock::s_top = NULL;
|
CXWindowsUtil::CErrorLock* CXWindowsUtil::CErrorLock::s_top = NULL;
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock::CErrorLock()
|
CXWindowsUtil::CErrorLock::CErrorLock(Display* display) :
|
||||||
|
m_display(display)
|
||||||
{
|
{
|
||||||
install(&CXWindowsUtil::CErrorLock::ignoreHandler, NULL);
|
install(&CXWindowsUtil::CErrorLock::ignoreHandler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock::CErrorLock(bool* flag)
|
CXWindowsUtil::CErrorLock::CErrorLock(Display* display, bool* flag) :
|
||||||
|
m_display(display)
|
||||||
{
|
{
|
||||||
install(&CXWindowsUtil::CErrorLock::saveHandler, flag);
|
install(&CXWindowsUtil::CErrorLock::saveHandler, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock::CErrorLock(ErrorHandler handler, void* data)
|
CXWindowsUtil::CErrorLock::CErrorLock(Display* display,
|
||||||
|
ErrorHandler handler, void* data) :
|
||||||
|
m_display(display)
|
||||||
{
|
{
|
||||||
install(handler, data);
|
install(handler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock::~CErrorLock()
|
CXWindowsUtil::CErrorLock::~CErrorLock()
|
||||||
{
|
{
|
||||||
|
// make sure everything finishes before uninstalling handler
|
||||||
|
XSync(m_display, False);
|
||||||
|
|
||||||
|
// restore old handler
|
||||||
XSetErrorHandler(m_oldXHandler);
|
XSetErrorHandler(m_oldXHandler);
|
||||||
s_top = m_next;
|
s_top = m_next;
|
||||||
}
|
}
|
||||||
|
@ -203,6 +211,10 @@ CXWindowsUtil::CErrorLock::~CErrorLock()
|
||||||
void
|
void
|
||||||
CXWindowsUtil::CErrorLock::install(ErrorHandler handler, void* data)
|
CXWindowsUtil::CErrorLock::install(ErrorHandler handler, void* data)
|
||||||
{
|
{
|
||||||
|
// make sure everything finishes before installing handler
|
||||||
|
XSync(m_display, False);
|
||||||
|
|
||||||
|
// install handler
|
||||||
m_handler = handler;
|
m_handler = handler;
|
||||||
m_userData = data;
|
m_userData = data;
|
||||||
m_oldXHandler = XSetErrorHandler(
|
m_oldXHandler = XSetErrorHandler(
|
||||||
|
@ -221,13 +233,14 @@ CXWindowsUtil::CErrorLock::internalHandler(Display* display, XErrorEvent* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsUtil::CErrorLock::ignoreHandler(Display*, XErrorEvent*, void*)
|
CXWindowsUtil::CErrorLock::ignoreHandler(Display*, XErrorEvent* e, void*)
|
||||||
{
|
{
|
||||||
// do nothing
|
log((CLOG_DEBUG "ignoring X error: %d", e->error_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsUtil::CErrorLock::saveHandler(Display*, XErrorEvent*, void* flag)
|
CXWindowsUtil::CErrorLock::saveHandler(Display*, XErrorEvent* e, void* flag)
|
||||||
{
|
{
|
||||||
|
log((CLOG_DEBUG "flagging X error: %d", e->error_code));
|
||||||
*reinterpret_cast<bool*>(flag) = true;
|
*reinterpret_cast<bool*>(flag) = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ public:
|
||||||
class CErrorLock {
|
class CErrorLock {
|
||||||
public:
|
public:
|
||||||
typedef void (*ErrorHandler)(Display*, XErrorEvent*, void* userData);
|
typedef void (*ErrorHandler)(Display*, XErrorEvent*, void* userData);
|
||||||
CErrorLock();
|
CErrorLock(Display*);
|
||||||
CErrorLock(bool* errorFlag);
|
CErrorLock(Display*, bool* errorFlag);
|
||||||
CErrorLock(ErrorHandler, void* userData);
|
CErrorLock(Display*, ErrorHandler, void* userData);
|
||||||
~CErrorLock();
|
~CErrorLock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -44,6 +44,7 @@ public:
|
||||||
private:
|
private:
|
||||||
typedef int (*XErrorHandler)(Display*, XErrorEvent*);
|
typedef int (*XErrorHandler)(Display*, XErrorEvent*);
|
||||||
|
|
||||||
|
Display* m_display;
|
||||||
ErrorHandler m_handler;
|
ErrorHandler m_handler;
|
||||||
void* m_userData;
|
void* m_userData;
|
||||||
XErrorHandler m_oldXHandler;
|
XErrorHandler m_oldXHandler;
|
||||||
|
|
|
@ -617,7 +617,7 @@ CXWindowsPrimaryScreen::selectEvents(Display* display, Window w) const
|
||||||
// ignore errors while we adjust event masks. windows could be
|
// ignore errors while we adjust event masks. windows could be
|
||||||
// destroyed at any time after the XQueryTree() in doSelectEvents()
|
// destroyed at any time after the XQueryTree() in doSelectEvents()
|
||||||
// so we must ignore BadWindow errors.
|
// so we must ignore BadWindow errors.
|
||||||
CXWindowsUtil::CErrorLock lock;
|
CXWindowsUtil::CErrorLock lock(display);
|
||||||
|
|
||||||
// adjust event masks
|
// adjust event masks
|
||||||
doSelectEvents(display, w);
|
doSelectEvents(display, w);
|
||||||
|
|
Loading…
Reference in New Issue