summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-08-21 07:58:07 +0200
committerMontel Laurent <[email protected]>2017-08-21 07:58:07 +0200
commit30e131c9671c0262251bccbe9869351582c41810 (patch)
treeaefcb13129e33a8781a03755bccfdc81d2751f51
parentfe1f353e9b3055e1f03a2225651ad0638c245959 (diff)
Fix potential crash
-rw-r--r--src/libkdepimakonadi/job/addemailaddressjob.cpp17
-rw-r--r--src/libkdepimakonadi/job/addemaildisplayjob.cpp17
-rw-r--r--src/libkdepimakonadi/job/openemailaddressjob.cpp15
3 files changed, 29 insertions, 20 deletions
diff --git a/src/libkdepimakonadi/job/addemailaddressjob.cpp b/src/libkdepimakonadi/job/addemailaddressjob.cpp
index 229dd5e..09f4ae1 100644
--- a/src/libkdepimakonadi/job/addemailaddressjob.cpp
+++ b/src/libkdepimakonadi/job/addemailaddressjob.cpp
@@ -140,29 +140,32 @@ public:
i18nc("@info",
"You must create an address book before adding a contact. Do you want to create an address book?"),
i18nc("@title:window", "No Address Book Available")) == KMessageBox::Yes) {
- Akonadi::AgentTypeDialog dlg(mParentWidget);
- dlg.setWindowTitle(i18n("Add Address Book"));
- dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
- dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::ContactGroup::mimeType());
- dlg.agentFilterProxyModel()->addCapabilityFilter(QStringLiteral("Resource"));
+ QPointer<Akonadi::AgentTypeDialog> dlg = new Akonadi::AgentTypeDialog(mParentWidget);
+ dlg->setWindowTitle(i18n("Add Address Book"));
+ dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
+ dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::ContactGroup::mimeType());
+ dlg->agentFilterProxyModel()->addCapabilityFilter(QStringLiteral("Resource"));
- if (dlg.exec()) {
- const Akonadi::AgentType agentType = dlg.agentType();
+ if (dlg->exec()) {
+ const Akonadi::AgentType agentType = dlg->agentType();
if (agentType.isValid()) {
Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(agentType, q);
q->connect(job, SIGNAL(result(KJob *)), SLOT(slotResourceCreationDone(KJob *)));
job->configure(mParentWidget);
job->start();
+ delete dlg;
return;
} else { //if agent is not valid => return error and finish job
q->setError(UserDefinedError);
q->emitResult();
+ delete dlg;
return;
}
} else { //Canceled create agent => return error and finish job
q->setError(UserDefinedError);
q->emitResult();
+ delete dlg;
return;
}
} else {
diff --git a/src/libkdepimakonadi/job/addemaildisplayjob.cpp b/src/libkdepimakonadi/job/addemaildisplayjob.cpp
index e201590..1ff0499 100644
--- a/src/libkdepimakonadi/job/addemaildisplayjob.cpp
+++ b/src/libkdepimakonadi/job/addemaildisplayjob.cpp
@@ -158,29 +158,32 @@ public:
i18nc("@info",
"You must create an address book before adding a contact. Do you want to create an address book?"),
i18nc("@title:window", "No Address Book Available")) == KMessageBox::Yes) {
- Akonadi::AgentTypeDialog dlg(mParentWidget);
- dlg.setWindowTitle(i18n("Add Address Book"));
- dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
- dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::ContactGroup::mimeType());
- dlg.agentFilterProxyModel()->addCapabilityFilter(QStringLiteral("Resource"));
+ QPointer<Akonadi::AgentTypeDialog> dlg = new Akonadi::AgentTypeDialog(mParentWidget);
+ dlg->setWindowTitle(i18n("Add Address Book"));
+ dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
+ dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::ContactGroup::mimeType());
+ dlg->agentFilterProxyModel()->addCapabilityFilter(QStringLiteral("Resource"));
- if (dlg.exec()) {
- const Akonadi::AgentType agentType = dlg.agentType();
+ if (dlg->exec()) {
+ const Akonadi::AgentType agentType = dlg->agentType();
if (agentType.isValid()) {
Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(agentType, q);
q->connect(job, SIGNAL(result(KJob *)), SLOT(slotResourceCreationDone(KJob *)));
job->configure(mParentWidget);
job->start();
+ delete dlg;
return;
} else { //if agent is not valid => return error and finish job
q->setError(UserDefinedError);
q->emitResult();
+ delete dlg;
return;
}
} else { //Canceled create agent => return error and finish job
q->setError(UserDefinedError);
q->emitResult();
+ delete dlg;
return;
}
} else {
diff --git a/src/libkdepimakonadi/job/openemailaddressjob.cpp b/src/libkdepimakonadi/job/openemailaddressjob.cpp
index 46379ac..114bcb9 100644
--- a/src/libkdepimakonadi/job/openemailaddressjob.cpp
+++ b/src/libkdepimakonadi/job/openemailaddressjob.cpp
@@ -27,6 +27,7 @@
#include <item.h>
#include <itemcreatejob.h>
#include <kcontacts/addressee.h>
+#include <QPointer>
#include <kmessagebox.h>
using namespace KPIM;
@@ -56,9 +57,10 @@ public:
const Akonadi::Item::List contacts = searchJob->items();
if (!contacts.isEmpty()) {
// open the editor with the matching item
- Akonadi::ContactEditorDialog dlg(Akonadi::ContactEditorDialog::EditMode, mParentWidget);
- dlg.setContact(contacts.first());
- dlg.exec();
+ QPointer<Akonadi::ContactEditorDialog> dlg = new Akonadi::ContactEditorDialog (Akonadi::ContactEditorDialog::EditMode, mParentWidget);
+ dlg->setContact(contacts.first());
+ dlg->exec();
+ delete dlg;
q->emitResult();
return;
@@ -81,9 +83,10 @@ public:
const AddEmailAddressJob *createJob = qobject_cast<AddEmailAddressJob *>(job);
// open the editor with the matching item
- Akonadi::ContactEditorDialog dlg(Akonadi::ContactEditorDialog::EditMode, mParentWidget);
- dlg.setContact(createJob->contact());
- dlg.exec();
+ QPointer<Akonadi::ContactEditorDialog> dlg = new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::EditMode, mParentWidget);
+ dlg->setContact(createJob->contact());
+ dlg->exec();
+ delete dlg;
q->emitResult();
}