Use std::unique_ptr in sparkle updater class rather than manual management

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-02-22 22:44:17 +01:00 committed by Matthieu Gallien
parent 0f30993b2c
commit 88b2ae0d21
2 changed files with 14 additions and 13 deletions

View File

@ -26,7 +26,7 @@ class SparkleUpdater : public Updater
Q_OBJECT
public:
SparkleUpdater(const QUrl &appCastUrl);
~SparkleUpdater() override;
~SparkleUpdater();
void setUpdateUrl(const QUrl &url);
@ -39,7 +39,7 @@ public:
private:
class Private;
Private *d;
std::unique_ptr<Private> d;
};
} // namespace OCC

View File

@ -76,19 +76,24 @@
namespace OCC {
class SparkleUpdater::Private
class Q_DECL_HIDDEN SparkleUpdater::Private
{
public:
SUUpdater* updater;
DelegateObject *delegate;
public:
~Private()
{
[updater release];
[delegate release];
}
SUUpdater* updater;
DelegateObject *delegate;
};
// Delete ~/Library//Preferences/com.owncloud.desktopclient.plist to re-test
SparkleUpdater::SparkleUpdater(const QUrl& appCastUrl)
: Updater()
, d(std::make_unique<Private>())
{
d = new Private;
d->delegate = [[DelegateObject alloc] init];
[d->delegate retain];
@ -107,11 +112,7 @@ SparkleUpdater::SparkleUpdater(const QUrl& appCastUrl)
[d->updater setUserAgentString: userAgent];
}
SparkleUpdater::~SparkleUpdater()
{
[d->updater release];
delete d;
}
SparkleUpdater::~SparkleUpdater() = default;
void SparkleUpdater::setUpdateUrl(const QUrl &url)
{