Skip to content

Commit

Permalink
avoid memory leak in slave jobs
Browse files Browse the repository at this point in the history
Summary:
Making ~SlaveInterface virtual, the connection created in Slave constructor is now deleted. (thanks @dfaure).
Changed to new connect syntax.

BUG: 396651

Test Plan:
The leaks of the bug report are gone.

Reviewers: dfaure, #frameworks, ngraham

Reviewed By: dfaure

Subscribers: anthonyfieroni, apol, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D14253
  • Loading branch information
pauser0000001 committed Jul 21, 2018
1 parent 671e6e0 commit 021daba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/slave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void Slave::accept()
d->slaveconnserver->deleteLater();
d->slaveconnserver = nullptr;

connect(d->connection, SIGNAL(readyRead()), SLOT(gotInput()));
connect(d->connection, &Connection::readyRead, this, &Slave::gotInput);
}

void Slave::timeout()
Expand Down Expand Up @@ -218,7 +218,7 @@ Slave::Slave(const QString &protocol, QObject *parent)
Q_D(Slave);
d->slaveconnserver->setParent(this);
d->connection = new Connection(this);
connect(d->slaveconnserver, SIGNAL(newConnection()), SLOT(accept()));
connect(d->slaveconnserver, &ConnectionServer::newConnection, this, &Slave::accept);
}

Slave::~Slave()
Expand Down
2 changes: 1 addition & 1 deletion src/core/slaveinterface_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class KIO::SlaveInterfacePrivate
nums(0), slave_calcs_speed(false)
{
}
~SlaveInterfacePrivate()
virtual ~SlaveInterfacePrivate()
{
delete connection;
}
Expand Down

0 comments on commit 021daba

Please sign in to comment.