diff options
author | hbarker <hc-barker@users.noreply.github.com> | 2019-09-25 04:29:12 +0300 |
---|---|---|
committer | Davide Beatrici <davidebeatrici@gmail.com> | 2019-09-25 04:51:12 +0300 |
commit | e2b15e5aea852f0569d37096c4a130b38397ffce (patch) | |
tree | 2d89569b3eacdedc9b5f21d1f32cbe4cb8e7ec00 | |
parent | a0c92b5463e56e2299f85df0e97218f4d154bfcb (diff) |
OverlayClient: convert raw pointers to QScopedPointer(s)
-rw-r--r-- | src/mumble/OverlayClient.cpp | 30 | ||||
-rw-r--r-- | src/mumble/OverlayClient.h | 11 |
2 files changed, 18 insertions, 23 deletions
diff --git a/src/mumble/OverlayClient.cpp b/src/mumble/OverlayClient.cpp index ceb3722c1..735d6c88e 100644 --- a/src/mumble/OverlayClient.cpp +++ b/src/mumble/OverlayClient.cpp @@ -59,7 +59,7 @@ OverlayClient::OverlayClient(QLocalSocket *socket, QObject *p) // Make sure it has a native window id qgv.winId(); - qgpiCursor = new OverlayMouse(); + qgpiCursor.reset(new OverlayMouse()); qgpiCursor->hide(); qgpiCursor->setZValue(10.0f); @@ -67,30 +67,23 @@ OverlayClient::OverlayClient(QLocalSocket *socket, QObject *p) qgs.addItem(&ougUsers); ougUsers.show(); - qgpiFPS = new OverlayPositionableItem(&g.s.os.qrfFps); - qgs.addItem(qgpiFPS); + qgpiFPS.reset(new OverlayPositionableItem(&g.s.os.qrfFps)); + qgs.addItem(qgpiFPS.data()); qgpiFPS->setPos(g.s.os.qrfFps.x(), g.s.os.qrfFps.y()); qgpiFPS->show(); // Time - qgpiTime = new OverlayPositionableItem(&g.s.os.qrfTime); - qgs.addItem(qgpiTime); + qgpiTime.reset(new OverlayPositionableItem(&g.s.os.qrfTime)); + qgs.addItem(qgpiTime.data()); qgpiTime->setPos(g.s.os.qrfTime.x(), g.s.os.qrfTime.y()); qgpiTime->show(); - qgpiLogo = NULL; - iOffsetX = iOffsetY = 0; connect(&qgs, SIGNAL(changed(const QList<QRectF> &)), this, SLOT(changed(const QList<QRectF> &))); } OverlayClient::~OverlayClient() { - delete qgpiFPS; - delete qgpiTime; - delete qgpiCursor; - delete qgpiLogo; - qlsSocket->disconnectFromServer(); if (!qlsSocket->waitForDisconnected(1000)) { qDebug() << "OverlayClient: Failed to cleanly disconnect: " << qlsSocket->errorString(); @@ -514,8 +507,7 @@ void OverlayClient::reset() { if (! uiWidth || ! uiHeight || ! smMem) return; - delete qgpiLogo; - qgpiLogo = NULL; + qgpiLogo.reset(); ougUsers.reset(); @@ -527,7 +519,7 @@ void OverlayClient::setupScene(bool show) { qgs.setBackgroundBrush(QColor(0,0,0,64)); if (! qgpiLogo) { - qgpiLogo = new OverlayMouse(); + qgpiLogo.reset(new OverlayMouse()); qgpiLogo->hide(); qgpiLogo->setOpacity(0.8f); qgpiLogo->setZValue(-5.0f); @@ -546,20 +538,20 @@ void OverlayClient::setupScene(bool show) { } qgpiCursor->show(); - qgs.addItem(qgpiCursor); + qgs.addItem(qgpiCursor.data()); qgpiLogo->show(); - qgs.addItem(qgpiLogo); + qgs.addItem(qgpiLogo.data()); } else { qgs.setBackgroundBrush(Qt::NoBrush); if (qgpiCursor->scene()) - qgs.removeItem(qgpiCursor); + qgs.removeItem(qgpiCursor.data()); qgpiCursor->hide(); if (qgpiLogo) { if (qgpiLogo->scene()) - qgs.removeItem(qgpiLogo); + qgs.removeItem(qgpiLogo.data()); qgpiLogo->hide(); } diff --git a/src/mumble/OverlayClient.h b/src/mumble/OverlayClient.h index 0fee3befa..5419f0453 100644 --- a/src/mumble/OverlayClient.h +++ b/src/mumble/OverlayClient.h @@ -6,6 +6,7 @@ #ifndef MUMBLE_MUMBLE_OVERLAYCLIENT_H_ #define MUMBLE_MUMBLE_OVERLAYCLIENT_H_ +#include <QtCore/QScopedPointer> #include <QtCore/QUrl> #include <QtNetwork/QLocalSocket> @@ -34,10 +35,6 @@ class OverlayClient : public QObject { float framesPerSecond; int iOffsetX, iOffsetY; - QGraphicsPixmapItem *qgpiCursor; - QGraphicsPixmapItem *qgpiLogo; - OverlayPositionableItem *qgpiFPS; - OverlayPositionableItem *qgpiTime; /// The process ID of the process this OverlayClient is connected to. quint64 uiPid; @@ -45,6 +42,12 @@ class OverlayClient : public QObject { QString qsExecutablePath; QGraphicsScene qgs; + + QScopedPointer<QGraphicsPixmapItem> qgpiCursor; + QScopedPointer<QGraphicsPixmapItem> qgpiLogo; + QScopedPointer<OverlayPositionableItem> qgpiFPS; + QScopedPointer<OverlayPositionableItem> qgpiTime; + OverlayUserGroup ougUsers; #ifdef Q_OS_MAC |