Skip to content

Commit

Permalink
Add todo regarding PartitionManagerPrivate leaking
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Nov 28, 2018
1 parent 5f315b1 commit 7b6a8ed
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/partitionmanager_p.h
Expand Up @@ -90,6 +90,7 @@ class PartitionManagerPrivate : public QObject, public QSharedData
void formatError(Partition::Error error);

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

Partitions m_partitions;
Expand Down
4 changes: 2 additions & 2 deletions src/udisks2blockdevices.cpp
Expand Up @@ -42,11 +42,11 @@

using namespace UDisks2;

BlockDevices *BlockDevices::sharedInstance = nullptr;
QPointer<BlockDevices> BlockDevices::sharedInstance = nullptr;

BlockDevices *BlockDevices::instance()
{
return sharedInstance ? sharedInstance : new BlockDevices;
return sharedInstance ? sharedInstance.data() : new BlockDevices;
}

BlockDevices::~BlockDevices()
Expand Down
4 changes: 3 additions & 1 deletion src/udisks2blockdevices_p.h
Expand Up @@ -33,6 +33,8 @@
#define UDISKS2_BLOCK_DEVICES_H

#include <QMap>
#include <QPointer>

#include "udisks2block_p.h"

class QTimerEvent;
Expand Down Expand Up @@ -98,7 +100,7 @@ private slots:
QMap<QString, Block *> m_blockDevices;
QMap<QString, PartitionWaiter*> m_partitionWaits;

static BlockDevices *sharedInstance;
static QPointer<BlockDevices> sharedInstance;
};

}
Expand Down
3 changes: 3 additions & 0 deletions src/udisks2monitor.cpp
Expand Up @@ -132,6 +132,9 @@ UDisks2::Monitor::~Monitor()
sharedInstance = nullptr;
qDeleteAll(m_jobsToWait);
m_jobsToWait.clear();

delete m_blockDevices;
m_blockDevices = nullptr;
}

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

0 comments on commit 7b6a8ed

Please sign in to comment.