Fix a small memory leak in QXcbIntegration.

Prefer to use a smart pointer over a raw pointer.

Change-Id: If8b5cbef8767433eab2f82c14abaa9608b8e61d0
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Jędrzej Nowacki 2011-11-18 10:05:25 +01:00 committed by Qt by Nokia
parent 3ad7ddf265
commit a291519e3e
2 changed files with 12 additions and 15 deletions

View File

@ -103,18 +103,15 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters)
foreach (QXcbScreen *screen, connection->screens())
screenAdded(screen);
m_fontDatabase = new QGenericUnixFontDatabase();
m_nativeInterface = new QXcbNativeInterface;
m_inputContext = QPlatformInputContextFactory::create();
m_accessibility = new QPlatformAccessibility();
m_fontDatabase.reset(new QGenericUnixFontDatabase());
m_nativeInterface.reset(new QXcbNativeInterface);
m_inputContext.reset(QPlatformInputContextFactory::create());
m_accessibility.reset(new QPlatformAccessibility());
}
QXcbIntegration::~QXcbIntegration()
{
qDeleteAll(m_connections);
delete m_accessibility;
}
QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
@ -214,12 +211,12 @@ void QXcbIntegration::moveToScreen(QWindow *window, int screen)
QPlatformFontDatabase *QXcbIntegration::fontDatabase() const
{
return m_fontDatabase;
return m_fontDatabase.data();
}
QPlatformNativeInterface * QXcbIntegration::nativeInterface() const
{
return m_nativeInterface;
return m_nativeInterface.data();
}
QPlatformClipboard *QXcbIntegration::clipboard() const
@ -234,12 +231,12 @@ QPlatformDrag *QXcbIntegration::drag() const
QPlatformInputContext *QXcbIntegration::inputContext() const
{
return m_inputContext;
return m_inputContext.data();
}
QPlatformAccessibility *QXcbIntegration::accessibility() const
{
return m_accessibility;
return m_accessibility.data();
}
QT_END_NAMESPACE

View File

@ -79,13 +79,13 @@ public:
private:
QList<QXcbConnection *> m_connections;
QPlatformFontDatabase *m_fontDatabase;
QPlatformNativeInterface *m_nativeInterface;
QScopedPointer<QPlatformFontDatabase> m_fontDatabase;
QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformInputContext> m_inputContext;
QAbstractEventDispatcher *m_eventDispatcher;
QPlatformAccessibility *m_accessibility;
QScopedPointer<QPlatformAccessibility> m_accessibility;
};
QT_END_NAMESPACE