Skip to content

Commit d10c891

Browse files
committed
private pointer now scoped (cleaner)
1 parent aaa31eb commit d10c891

File tree

8 files changed

+11
-15
lines changed

8 files changed

+11
-15
lines changed

AutoUpdaterCore/updater.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ Updater::Updater(const QString &maintenanceToolPath, QObject *parent) :
2323
d->toolPath = UpdaterPrivate::toSystemExe(maintenanceToolPath);
2424
}
2525

26-
Updater::~Updater()
27-
{
28-
delete this->d_ptr;
29-
}
26+
Updater::~Updater() {}
3027

3128
bool Updater::exitedNormally() const
3229
{

AutoUpdaterCore/updater.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <QDateTime>
99
#include <QVersionNumber>
1010
#include <QLoggingCategory>
11+
#include <QScopedPointer>
1112
#include "adminauthoriser.h"
1213

1314
namespace QtAutoUpdater
@@ -100,7 +101,7 @@ namespace QtAutoUpdater
100101
void updateInfoChanged(QList<QtAutoUpdater::Updater::UpdateInfo> updateInfo);
101102

102103
private:
103-
UpdaterPrivate *d_ptr;
104+
QScopedPointer<UpdaterPrivate> d_ptr;
104105
Q_DECLARE_PRIVATE(Updater)
105106
};
106107
}

AutoUpdaterGui/updatebutton.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ UpdateButton::UpdateButton(QWidget *parent, UpdateController *controller) :
1010
d_ptr(new UpdateButtonPrivate(this, controller))
1111
{}
1212

13-
UpdateButton::~UpdateButton()
14-
{
15-
delete this->d_ptr;
16-
}
13+
UpdateButton::~UpdateButton(){}
1714

1815
QString UpdateButton::animationFile() const
1916
{

AutoUpdaterGui/updatebutton.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define UPDATEBUTTON_H
33

44
#include <QWidget>
5+
#include <QScopedPointer>
56
#include "updatecontroller.h"
67

78
namespace QtAutoUpdater
@@ -65,7 +66,7 @@ namespace QtAutoUpdater
6566
void controllerDestroyed();
6667

6768
private:
68-
UpdateButtonPrivate *d_ptr;
69+
QScopedPointer<UpdateButtonPrivate> d_ptr;
6970
Q_DECLARE_PRIVATE(UpdateButton)
7071
UpdateController* m_controller;
7172
};

AutoUpdaterGui/updatebutton_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace QtAutoUpdater
1313
{
1414
class UpdateButtonPrivate
1515
{
16+
public:
1617
UpdateButton *q_ptr;
1718
Q_DECLARE_PUBLIC(UpdateButton)
1819

AutoUpdaterGui/updatecontroller.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ UpdateController::UpdateController(const QString &maintenanceToolPath, QWidget *
3535
d_ptr(new UpdateControllerPrivate(this, maintenanceToolPath, parentWidget))
3636
{}
3737

38-
UpdateController::~UpdateController()
39-
{
40-
delete this->d_ptr;
41-
}
38+
UpdateController::~UpdateController(){}
4239

4340
QAction *UpdateController::createUpdateAction(QObject *parent)
4441
{

AutoUpdaterGui/updatecontroller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <QObject>
55
#include <QAction>
66
#include <QStringList>
7+
#include <QScopedPointer>
78

89
namespace QtAutoUpdater
910
{
@@ -108,7 +109,7 @@ namespace QtAutoUpdater
108109
void timerTriggered(const QVariant &parameter);
109110

110111
private:
111-
UpdateControllerPrivate *d_ptr;
112+
QScopedPointer<UpdateControllerPrivate> d_ptr;
112113
Q_DECLARE_PRIVATE(UpdateController)
113114
};
114115
}

AutoUpdaterGui/updatecontroller_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace QtAutoUpdater
1212
{
1313
class UpdateControllerPrivate//TODO load icon indirectly -> easier replacement
1414
{
15+
public:
1516
typedef QPair<UpdateController::DisplayLevel, bool> UpdateTask;
1617

1718
UpdateController *q_ptr;

0 commit comments

Comments
 (0)