mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
main: Stop leaking pointers when we do not enter the main app loop.
In the cases where we returned before calling KApplication::exec(), we would end up leaking pointers such as |batchJob|, |window| and |addToArchiveJob|. Fix it by explicitly deleting |window| (since we do not have another QWidget to make it a child of) and making |batchJob| and |addToArchiveJob| be children of our main KApplication so that we do not need to explicitly delete them under any circumstances.
This commit is contained in:
parent
7f39b7ec2e
commit
3eb01a3ecd
4 changed files with 6 additions and 6 deletions
|
@ -46,8 +46,8 @@
|
|||
#include <QTimer>
|
||||
#include <QWeakPointer>
|
||||
|
||||
BatchExtract::BatchExtract()
|
||||
: KCompositeJob(0),
|
||||
BatchExtract::BatchExtract(QObject* parent)
|
||||
: KCompositeJob(parent),
|
||||
m_autoSubfolder(false),
|
||||
m_preservePaths(true),
|
||||
m_openDestinationAfterExtraction(false)
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
/**
|
||||
* Creates a new BatchExtract object.
|
||||
*/
|
||||
BatchExtract();
|
||||
explicit BatchExtract(QObject* parent = 0);
|
||||
|
||||
/**
|
||||
* Destroys a BatchExtract object.
|
||||
|
|
|
@ -49,7 +49,6 @@ void ExtractHereDndPlugin::slotTriggered()
|
|||
|
||||
batchJob->start();
|
||||
kDebug() << "Started job";
|
||||
|
||||
}
|
||||
|
||||
ExtractHereDndPlugin::ExtractHereDndPlugin(QObject* parent, const QVariantList&)
|
||||
|
|
|
@ -129,7 +129,7 @@ int main(int argc, char **argv)
|
|||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||
|
||||
if (args->isSet("add") || args->isSet("add-to")) {
|
||||
AddToArchive *addToArchiveJob = new AddToArchive;
|
||||
AddToArchive *addToArchiveJob = new AddToArchive(&application);
|
||||
application.connect(addToArchiveJob, SIGNAL(result(KJob*)), SLOT(quit()), Qt::QueuedConnection);
|
||||
|
||||
if (args->isSet("changetofirstpath")) {
|
||||
|
@ -157,7 +157,7 @@ int main(int argc, char **argv)
|
|||
|
||||
addToArchiveJob->start();
|
||||
} else if (args->isSet("batch")) {
|
||||
BatchExtract *batchJob = new BatchExtract;
|
||||
BatchExtract *batchJob = new BatchExtract(&application);
|
||||
application.connect(batchJob, SIGNAL(result(KJob*)), SLOT(quit()), Qt::QueuedConnection);
|
||||
|
||||
for (int i = 0; i < args->count(); ++i) {
|
||||
|
@ -190,6 +190,7 @@ int main(int argc, char **argv)
|
|||
} else {
|
||||
MainWindow *window = new MainWindow;
|
||||
if (!window->loadPart()) { // if loading the part fails
|
||||
delete window;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue