Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 7b6a8ed

Browse files
committed
Add todo regarding PartitionManagerPrivate leaking
1 parent 5f315b1 commit 7b6a8ed

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/partitionmanager_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class PartitionManagerPrivate : public QObject, public QSharedData
9090
void formatError(Partition::Error error);
9191

9292
private:
93+
// TODO: This is leaking (Disks2::Monitor is never free'ed).
9394
static PartitionManagerPrivate *sharedInstance;
9495

9596
Partitions m_partitions;

src/udisks2blockdevices.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242

4343
using namespace UDisks2;
4444

45-
BlockDevices *BlockDevices::sharedInstance = nullptr;
45+
QPointer<BlockDevices> BlockDevices::sharedInstance = nullptr;
4646

4747
BlockDevices *BlockDevices::instance()
4848
{
49-
return sharedInstance ? sharedInstance : new BlockDevices;
49+
return sharedInstance ? sharedInstance.data() : new BlockDevices;
5050
}
5151

5252
BlockDevices::~BlockDevices()

src/udisks2blockdevices_p.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#define UDISKS2_BLOCK_DEVICES_H
3434

3535
#include <QMap>
36+
#include <QPointer>
37+
3638
#include "udisks2block_p.h"
3739

3840
class QTimerEvent;
@@ -98,7 +100,7 @@ private slots:
98100
QMap<QString, Block *> m_blockDevices;
99101
QMap<QString, PartitionWaiter*> m_partitionWaits;
100102

101-
static BlockDevices *sharedInstance;
103+
static QPointer<BlockDevices> sharedInstance;
102104
};
103105

104106
}

src/udisks2monitor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ UDisks2::Monitor::~Monitor()
132132
sharedInstance = nullptr;
133133
qDeleteAll(m_jobsToWait);
134134
m_jobsToWait.clear();
135+
136+
delete m_blockDevices;
137+
m_blockDevices = nullptr;
135138
}
136139

137140
// TODO : Move lock, unlock, mount, unmount, format inside udisks2block.cpp

0 commit comments

Comments
 (0)