diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-08 11:40:26 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-08 12:17:04 (GMT) |
commit | 32a2ccfedd0aa09311a173525f89f8e4894319f6 (patch) | |
tree | 2891f50c157f926ec57e3e0499e350dab574942d /src/plugins/platforms/wayland | |
parent | 41132f22be02fe4ec73e8e3b5795bdd630344414 (diff) | |
download | Qt-32a2ccfedd0aa09311a173525f89f8e4894319f6.zip Qt-32a2ccfedd0aa09311a173525f89f8e4894319f6.tar.gz Qt-32a2ccfedd0aa09311a173525f89f8e4894319f6.tar.bz2 |
Prevented crash due to dangling pointer in QWaylandInputDevice.
When a QWaylandWindow is destroyed we need to make sure it's not still
referenced by QWaylandInputDevice.
Diffstat (limited to 'src/plugins/platforms/wayland')
4 files changed, 18 insertions, 2 deletions
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index ac0ad71..e02767d 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -76,11 +76,13 @@ public: #endif void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y); - void syncCallback(wl_display_sync_func_t func, void *data); void frameCallback(wl_display_frame_func_t func, void *data); struct wl_display *wl_display() const { return mDisplay; } + + QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; } + public slots: void createNewScreen(struct wl_output *output, QRect geometry); void readEvents(); diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 47f9c91..6c2f341 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -83,6 +83,14 @@ QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display, #endif } +void QWaylandInputDevice::handleWindowDestroyed(QWaylandWindow *window) +{ + if (window == mPointerFocus) + mPointerFocus = 0; + if (window == mKeyboardFocus) + mKeyboardFocus = 0; +} + void QWaylandInputDevice::inputHandleMotion(void *data, struct wl_input_device *input_device, uint32_t time, diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h index 2328db8..3c83252 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h @@ -59,6 +59,7 @@ class QWaylandInputDevice { public: QWaylandInputDevice(struct wl_display *display, uint32_t id); void attach(QWaylandBuffer *buffer, int x, int y); + void handleWindowDestroyed(QWaylandWindow *window); private: struct wl_display *mDisplay; diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index c7cd147..d58b39d 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -41,9 +41,10 @@ #include "qwaylandwindow.h" +#include "qwaylandbuffer.h" #include "qwaylanddisplay.h" +#include "qwaylandinputdevice.h" #include "qwaylandscreen.h" -#include "qwaylandbuffer.h" #include <QtGui/QWidget> #include <QtGui/QWindowSystemInterface> @@ -66,6 +67,10 @@ QWaylandWindow::~QWaylandWindow() { if (mSurface) wl_surface_destroy(mSurface); + + QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices(); + for (int i = 0; i < inputDevices.size(); ++i) + inputDevices.at(i)->handleWindowDestroyed(this); } WId QWaylandWindow::winId() const |