summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-02-14 16:33:29 +0100
committerJørgen Lind <jorgen.lind@nokia.com>2012-02-15 20:37:14 +0100
commita6ba08ef1eeeaac4325ddbc9b4cf214dad32ed1e (patch)
treed9016c71ee9192fdd09149f024cfb8e0ed578674
parentaf808243e01b13f12c27527198968b0a83423fb6 (diff)
Compositor memory leak fixes
Change-Id: Ia0510e00ffc925cde98ec5345a8129d1979c478c Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
-rw-r--r--src/compositor/compositor_api/waylandinput.cpp5
-rw-r--r--src/compositor/compositor_api/waylandinput.h1
-rw-r--r--src/compositor/hardware_integration/graphicshardwareintegration.h1
-rw-r--r--src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp10
-rw-r--r--src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h4
-rw-r--r--src/compositor/wayland_wrapper/wlcompositor.cpp20
-rw-r--r--src/compositor/wayland_wrapper/wlcompositor.h2
-rw-r--r--src/compositor/wayland_wrapper/wlinputdevice.cpp13
-rw-r--r--src/compositor/wayland_wrapper/wlinputdevice.h3
-rw-r--r--src/compositor/wayland_wrapper/wloutput.cpp12
-rw-r--r--src/compositor/wayland_wrapper/wloutput.h5
-rw-r--r--src/compositor/wayland_wrapper/wlsurface.cpp4
-rw-r--r--src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp13
-rw-r--r--src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h2
14 files changed, 81 insertions, 14 deletions
diff --git a/src/compositor/compositor_api/waylandinput.cpp b/src/compositor/compositor_api/waylandinput.cpp
index d0c45e972..2ae060402 100644
--- a/src/compositor/compositor_api/waylandinput.cpp
+++ b/src/compositor/compositor_api/waylandinput.cpp
@@ -50,6 +50,11 @@ WaylandInputDevice::WaylandInputDevice(WaylandCompositor *compositor)
{
}
+WaylandInputDevice::~WaylandInputDevice()
+{
+ delete d;
+}
+
void WaylandInputDevice::sendMousePressEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos)
{
d->sendMousePressEvent(button,localPos,globalPos);
diff --git a/src/compositor/compositor_api/waylandinput.h b/src/compositor/compositor_api/waylandinput.h
index 272d4c3dc..5f86b10e3 100644
--- a/src/compositor/compositor_api/waylandinput.h
+++ b/src/compositor/compositor_api/waylandinput.h
@@ -58,6 +58,7 @@ class Q_COMPOSITOR_EXPORT WaylandInputDevice
{
public:
WaylandInputDevice(WaylandCompositor *compositor);
+ ~WaylandInputDevice();
void sendMousePressEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos = QPoint());
void sendMouseReleaseEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos = QPoint());
diff --git a/src/compositor/hardware_integration/graphicshardwareintegration.h b/src/compositor/hardware_integration/graphicshardwareintegration.h
index aea16453f..cad28822e 100644
--- a/src/compositor/hardware_integration/graphicshardwareintegration.h
+++ b/src/compositor/hardware_integration/graphicshardwareintegration.h
@@ -52,6 +52,7 @@ class GraphicsHardwareIntegration
{
public:
GraphicsHardwareIntegration(WaylandCompositor *compositor);
+ virtual ~GraphicsHardwareIntegration() { }
virtual void initializeHardware(Wayland::Display *waylandDisplay) = 0;
diff --git a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp b/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp
index faf7beb44..a841826c1 100644
--- a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp
+++ b/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp
@@ -81,6 +81,7 @@ GraphicsHardwareIntegration *GraphicsHardwareIntegration::createGraphicsHardware
XCompositeGLXIntegration::XCompositeGLXIntegration(WaylandCompositor *compositor)
: GraphicsHardwareIntegration(compositor)
, mDisplay(0)
+ , mHandler(0)
{
QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface();
if (nativeInterface) {
@@ -93,10 +94,15 @@ XCompositeGLXIntegration::XCompositeGLXIntegration(WaylandCompositor *compositor
mScreen = XDefaultScreen(mDisplay);
}
+XCompositeGLXIntegration::~XCompositeGLXIntegration()
+{
+ delete mHandler;
+}
+
void XCompositeGLXIntegration::initializeHardware(Wayland::Display *waylandDisplay)
{
- XCompositeHandler *handler = new XCompositeHandler(m_compositor->handle(),mDisplay,m_compositor->window());
- wl_display_add_global(waylandDisplay->handle(),&wl_xcomposite_interface,handler,XCompositeHandler::xcomposite_bind_func);
+ mHandler = new XCompositeHandler(m_compositor->handle(),mDisplay,m_compositor->window());
+ wl_display_add_global(waylandDisplay->handle(),&wl_xcomposite_interface,mHandler,XCompositeHandler::xcomposite_bind_func);
QOpenGLContext *glContext = new QOpenGLContext();
glContext->create();
diff --git a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h b/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h
index e77e1f097..913a69a09 100644
--- a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h
+++ b/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h
@@ -49,10 +49,13 @@
#include <GL/glx.h>
#include <GL/glxext.h>
+class XCompositeHandler;
+
class XCompositeGLXIntegration : public GraphicsHardwareIntegration
{
public:
XCompositeGLXIntegration(WaylandCompositor *compositor);
+ ~XCompositeGLXIntegration();
void initializeHardware(Wayland::Display *waylandDisplay);
@@ -65,6 +68,7 @@ private:
Display *mDisplay;
int mScreen;
+ XCompositeHandler *mHandler;
};
#endif // XCOMPOSITEGLXINTEGRATION_H
diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp
index 1e1765b11..bd02b6709 100644
--- a/src/compositor/wayland_wrapper/wlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/wlcompositor.cpp
@@ -136,9 +136,9 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
wl_display_add_global(m_display->handle(),&wl_output_interface, &m_output_global,OutputGlobal::output_bind_func);
- wl_display_add_global(m_display->handle(), &wl_shell_interface, &m_shell, Shell::bind_func);
-
m_shell = new Shell();
+ wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell, Shell::bind_func);
+
m_outputExtension = new OutputExtensionGlobal(this);
m_surfaceExtension = new SurfaceExtensionGlobal(this);
@@ -159,9 +159,19 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
Compositor::~Compositor()
{
- delete m_default_input_device;
+ delete m_shell;
+ delete m_outputExtension;
+ delete m_surfaceExtension;
+ delete m_subSurfaceExtension;
+ delete m_touchExtension;
+
+ delete m_default_wayland_input_device;
delete m_data_device_manager;
+#ifdef QT_COMPOSITOR_WAYLAND_GL
+ delete m_graphics_hw_integration;
+#endif
+
delete m_display;
}
@@ -296,8 +306,8 @@ void Compositor::initializeHardwareIntegration()
void Compositor::initializeDefaultInputDevice()
{
- WaylandInputDevice *defaultInput = new WaylandInputDevice(m_qt_compositor);
- m_default_input_device = defaultInput->handle();
+ m_default_wayland_input_device = new WaylandInputDevice(m_qt_compositor);
+ m_default_input_device = m_default_wayland_input_device->handle();
}
void Compositor::initializeWindowManagerProtocol()
diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h
index b2d4ef6e7..d8acad2b1 100644
--- a/src/compositor/wayland_wrapper/wlcompositor.h
+++ b/src/compositor/wayland_wrapper/wlcompositor.h
@@ -52,6 +52,7 @@
#include <wayland-server.h>
class WaylandCompositor;
+class WaylandInputDevice;
class GraphicsHardwareIntegration;
class WindowManagerServerIntegration;
class QMimeData;
@@ -144,6 +145,7 @@ private:
Display *m_display;
/* Input */
+ WaylandInputDevice *m_default_wayland_input_device;
InputDevice *m_default_input_device;
/* Output */
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp
index b1c5cb74b..edf55d7fb 100644
--- a/src/compositor/wayland_wrapper/wlinputdevice.cpp
+++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp
@@ -61,6 +61,11 @@ InputDevice::InputDevice(WaylandInputDevice *handle, Compositor *compositor)
wl_display_add_global(compositor->wl_display(),&wl_input_device_interface,this,InputDevice::bind_func);
}
+InputDevice::~InputDevice()
+{
+ qDeleteAll(m_data_devices);
+}
+
void InputDevice::sendMousePressEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos)
{
sendMouseMoveEvent(localPos,globalPos);
@@ -225,12 +230,14 @@ void InputDevice::setMouseFocus(Surface *surface, const QPoint &globalPos, const
localPos.x(), localPos.y());
}
-void InputDevice::cleanupDataDeviceForClient(struct wl_client *client)
+void InputDevice::cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev)
{
for (int i = 0; i < m_data_devices.size(); i++) {
struct wl_resource *data_device_resource =
m_data_devices.at(i)->dataDeviceResource();
if (data_device_resource->client == client) {
+ if (destroyDev)
+ delete m_data_devices.at(i);
m_data_devices.removeAt(i);
break;
}
@@ -239,7 +246,7 @@ void InputDevice::cleanupDataDeviceForClient(struct wl_client *client)
void InputDevice::clientRequestedDataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id)
{
- cleanupDataDeviceForClient(client);
+ cleanupDataDeviceForClient(client, false);
DataDevice *dataDevice = new DataDevice(data_device_manager,client,id);
m_data_devices.append(dataDevice);
}
@@ -337,7 +344,7 @@ void InputDevice::destroy_resource(wl_resource *resource)
input_device->base()->pointer_focus_resource = 0;
}
- input_device->cleanupDataDeviceForClient(resource->client);
+ input_device->cleanupDataDeviceForClient(resource->client, true);
wl_list_remove(&resource->link);
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.h b/src/compositor/wayland_wrapper/wlinputdevice.h
index 05980b669..0519b753b 100644
--- a/src/compositor/wayland_wrapper/wlinputdevice.h
+++ b/src/compositor/wayland_wrapper/wlinputdevice.h
@@ -62,6 +62,7 @@ class InputDevice : public Object<struct wl_input_device>
{
public:
InputDevice(WaylandInputDevice *handle, Compositor *compositor);
+ ~InputDevice();
void sendMousePressEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos = QPoint());
void sendMouseReleaseEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos = QPoint());
@@ -91,7 +92,7 @@ public:
WaylandInputDevice *handle() const;
private:
- void cleanupDataDeviceForClient(struct wl_client *client);
+ void cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev);
WaylandInputDevice *m_handle;
Compositor *m_compositor;
diff --git a/src/compositor/wayland_wrapper/wloutput.cpp b/src/compositor/wayland_wrapper/wloutput.cpp
index 86b4d5b73..deae56d6e 100644
--- a/src/compositor/wayland_wrapper/wloutput.cpp
+++ b/src/compositor/wayland_wrapper/wloutput.cpp
@@ -39,6 +39,7 @@
****************************************************************************/
#include "wloutput.h"
+#include "wlextendedoutput.h"
#include <QGuiApplication>
#include <QtGui/QScreen>
#include <QRect>
@@ -53,6 +54,11 @@ OutputGlobal::OutputGlobal()
m_geometry = QRect(QPoint(0, 0), screen->availableGeometry().size());
}
+OutputGlobal::~OutputGlobal()
+{
+ qDeleteAll(m_outputs);
+}
+
void OutputGlobal::setGeometry(const QRect &geometry)
{
m_geometry = geometry;
@@ -71,6 +77,7 @@ void OutputGlobal::output_bind_func(struct wl_client *client, void *data,
Output *output = new Output(output_global,client,version,id);
output_global->registerResource(output->handle());
+ output_global->m_outputs.append(output);
}
@@ -89,6 +96,11 @@ Output::Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version,
}
+Output::~Output()
+{
+ delete m_extended_output;
+}
+
ExtendedOutput *Output::extendedOutput() const
{
return m_extended_output;
diff --git a/src/compositor/wayland_wrapper/wloutput.h b/src/compositor/wayland_wrapper/wloutput.h
index b637d2d3f..df7534f10 100644
--- a/src/compositor/wayland_wrapper/wloutput.h
+++ b/src/compositor/wayland_wrapper/wloutput.h
@@ -44,7 +44,7 @@
#include "waylandresourcecollection.h"
#include <QtCore/QRect>
-
+#include <QtCore/QList>
namespace Wayland {
@@ -55,6 +55,7 @@ class OutputGlobal : public ResourceCollection
{
public:
OutputGlobal();
+ ~OutputGlobal();
void setGeometry(const QRect &geometry);
QRect geometry() const { return m_geometry; }
@@ -71,6 +72,7 @@ private:
QRect m_geometry;
int m_displayId;
int m_numQueued;
+ QList<Output *> m_outputs;
};
@@ -78,6 +80,7 @@ class Output
{
public:
Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id);
+ ~Output();
OutputGlobal *outputGlobal() const;
diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp
index 5d6584935..2d96d6de1 100644
--- a/src/compositor/wayland_wrapper/wlsurface.cpp
+++ b/src/compositor/wayland_wrapper/wlsurface.cpp
@@ -48,6 +48,7 @@
#include "wlextendedsurface.h"
#include "wlsubsurface.h"
#include "wlsurfacebuffer.h"
+#include "wlshellsurface.h"
#include <QtCore/QDebug>
#include <QTouchEvent>
@@ -90,6 +91,9 @@ Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor)
Surface::~Surface()
{
delete m_waylandSurface;
+ delete m_extendedSurface;
+ delete m_subSurface;
+ delete m_shellSurface;
}
WaylandSurface::Type Surface::type() const
diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
index 1bec03c9a..f7e08c807 100644
--- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
+++ b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
@@ -51,6 +51,11 @@ WindowManagerServerIntegration::WindowManagerServerIntegration(QObject *parent)
{
}
+WindowManagerServerIntegration::~WindowManagerServerIntegration()
+{
+ qDeleteAll(m_managedClients);
+}
+
void WindowManagerServerIntegration::initialize(Wayland::Display *waylandDisplay)
{
wl_display_add_global(waylandDisplay->handle(),&wl_windowmanager_interface,this,WindowManagerServerIntegration::bind_func);
@@ -69,7 +74,9 @@ WaylandManagedClient *WindowManagerServerIntegration::managedClient(wl_client *c
void WindowManagerServerIntegration::mapClientToProcess(wl_client *client, uint32_t processId)
{
- WaylandManagedClient *managedClient = m_managedClients.value(client, new WaylandManagedClient);
+ WaylandManagedClient *managedClient = m_managedClients.value(client);
+ if (!managedClient)
+ managedClient = new WaylandManagedClient;
managedClient->m_processId = processId;
m_managedClients.insert(client, managedClient);
}
@@ -78,7 +85,9 @@ void WindowManagerServerIntegration::authenticateWithToken(wl_client *client, co
{
Q_ASSERT(token != 0 && *token != 0);
- WaylandManagedClient *managedClient = m_managedClients.value(client, new WaylandManagedClient);
+ WaylandManagedClient *managedClient = m_managedClients.value(client);
+ if (!managedClient)
+ managedClient = new WaylandManagedClient;
managedClient->m_authenticationToken = QByteArray(token);
m_managedClients.insert(client, managedClient);
diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
index 1b49a47b2..2077a7331 100644
--- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
+++ b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
@@ -66,6 +66,8 @@ class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QObject, priva
Q_OBJECT
public:
WindowManagerServerIntegration(QObject *parent = 0);
+ ~WindowManagerServerIntegration();
+
void initialize(Wayland::Display *waylandDisplay);
void removeClient(wl_client *client);