summaryrefslogtreecommitdiffstats
path: root/client/x11/red_window.cpp
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2010-04-01 12:11:44 +0300
committerIzik Eidus <ieidus@redhat.com>2010-04-03 05:55:00 +0300
commit6f40c593e96343c161e014fc8341c47d9a12acc7 (patch)
treeefd592c5ecd342d0099ce787cd595a4a392e1270 /client/x11/red_window.cpp
parent4a208b3644ab3a5e3e950400692303bf608f0129 (diff)
downloadspice-6f40c593e96343c161e014fc8341c47d9a12acc7.tar.gz
spice-6f40c593e96343c161e014fc8341c47d9a12acc7.tar.xz
spice-6f40c593e96343c161e014fc8341c47d9a12acc7.zip
client: x11: fix a crash caused by a call to a destroyed window.
Happens when a focused window is destroyed without a focus out event, and a focus-in event occurs on another window.
Diffstat (limited to 'client/x11/red_window.cpp')
-rw-r--r--client/x11/red_window.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 9a0423a9..6be3ba54 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -1051,11 +1051,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);
@@ -1163,7 +1169,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) {
@@ -1227,7 +1233,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();
}