summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2010-03-31 14:52:06 +0300
committerUri Lublin <uril@redhat.com>2010-04-04 14:32:21 +0300
commit78353dd51937136ac13232f6fac2ee0128244ac1 (patch)
tree0dd1640ab2202ebe841991c702e3c4b1db722bba
parent8700336b9788471f7380cc7049d32a88ca8be7df (diff)
client: x11: fix a crash caused by a call to a destroyed window. #578458spice-client-0.4.2-11.el6
Happens when a focused window is destroyed without a focus out event, and a focus-in event occurs on another window.
-rw-r--r--client/x11/red_window.cpp12
-rw-r--r--client/x11/red_window_p.h2
2 files changed, 10 insertions, 4 deletions
diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 6b4148b9..77c27ee7 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -1010,11 +1010,17 @@ RedWindow_p::RedWindow_p()
{
}
-void RedWindow_p::destroy(PixelsSource_p& pix_source)
+void RedWindow_p::destroy(RedWindow& red_window, PixelsSource_p& pix_source)
{
if (_win == None) {
return;
}
+
+ if (focus_window == &red_window) {
+ focus_window = NULL;
+ red_window.on_focus_out();
+ }
+
XPlatform::cleare_win_proc(_win);
XSelectInput(x_display, _win, 0);
XSync(x_display, False);
@@ -1122,7 +1128,7 @@ void RedWindow_p::migrate(RedWindow& red_window, PixelsSource_p& pix_source, int
}
XTextProperty text_pro;
bool valid_title = XGetWMName(x_display, _win, &text_pro) && text_pro.value;
- destroy(pix_source);
+ destroy(red_window, pix_source);
create(red_window, pix_source, _show_pos.x, _show_pos.y, attrib.width, attrib.height,
to_screen);
if (valid_title) {
@@ -1186,7 +1192,7 @@ RedWindow::RedWindow(RedWindow::Listener& listener, int screen)
RedWindow::~RedWindow()
{
- destroy(*(PixelsSource_p*)get_opaque());
+ destroy(*this, *(PixelsSource_p*)get_opaque());
if (_local_cursor) {
_local_cursor->unref();
}
diff --git a/client/x11/red_window_p.h b/client/x11/red_window_p.h
index ab9ce048..06440f97 100644
--- a/client/x11/red_window_p.h
+++ b/client/x11/red_window_p.h
@@ -36,7 +36,7 @@ public:
void migrate(RedWindow& red_window, PixelsSource_p& pix_source, int dest_screen);
void create(RedWindow& red_window, PixelsSource_p& pix_source, int x, int y,
unsigned int width, unsigned int height, int in_screen);
- void destroy(PixelsSource_p& pix_source);
+ void destroy(RedWindow& red_window, PixelsSource_p& pix_source);
void set_minmax(PixelsSource_p& pix_source, int width, int height);
void wait_for_reparent();
void wait_for_map();