Commit 3cfff0ce authored by David Faure's avatar David Faure
Browse files

Fix FakeAkonadiServerCommands being leaked

Summary:
Porting to unique_ptr would be complex here because each command
goes through the following containers, between creation and usage+deletion:
- QList<FakeJobResponse *>
- QList<FakeAkonadiServerCommand *>
- QQueue<FakeAkonadiServerCommand *>

Test Plan: tagmodeltest with ASAN (but it has other leaks)

Reviewers: dvratil

Reviewed By: dvratil

Subscribers: kde-pim

Differential Revision: https://phabricator.kde.org/D21139
parent 548c54a1
......@@ -61,10 +61,10 @@ FakeServerData::FakeServerData(TagModel *model, FakeSession *session, FakeMonito
}
void FakeServerData::setCommands(QList< FakeAkonadiServerCommand * > list)
void FakeServerData::setCommands(const QList<FakeAkonadiServerCommand *> &list)
{
m_communicationQueue.clear();
Q_FOREACH (FakeAkonadiServerCommand *command, list) {
for (FakeAkonadiServerCommand *command : list) {
m_communicationQueue << command;
}
}
......@@ -76,6 +76,7 @@ void FakeServerData::processNotifications()
if (respondTo == FakeAkonadiServerCommand::Notification) {
FakeAkonadiServerCommand *command = m_communicationQueue.dequeue();
command->doCommand();
delete command;
} else {
return;
}
......@@ -123,6 +124,7 @@ bool FakeServerData::returnCollections(Collection::Id fetchColId)
if (!m_communicationQueue.isEmpty()) {
returnEntities(fetchColId);
}
delete command;
return true;
}
return false;
......@@ -138,6 +140,7 @@ void FakeServerData::returnItems(Item::Id fetchColId)
if (!m_communicationQueue.isEmpty()) {
returnEntities(fetchColId);
}
delete command;
}
}
......@@ -148,5 +151,6 @@ void FakeServerData::returnTags()
if (commType == FakeAkonadiServerCommand::RespondToTagFetch) {
FakeAkonadiServerCommand *command = m_communicationQueue.dequeue();
command->doCommand();
delete command;
}
}
......@@ -39,7 +39,7 @@ public:
FakeServerData(EntityTreeModel *model, FakeSession *session, FakeMonitor *monitor, QObject *parent = nullptr);
FakeServerData(TagModel *model, FakeSession *session, FakeMonitor *monitor, QObject *parent = nullptr);
void setCommands(QList<FakeAkonadiServerCommand *> list);
void setCommands(const QList<FakeAkonadiServerCommand *> &list);
Collection::Id nextCollectionId() const
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment