Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 30e131c9 authored by Laurent Montel's avatar Laurent Montel 😁

Fix potential crash

parent fe1f353e
......@@ -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 {
......
......@@ -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 {
......
......@@ -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();
}
......
Markdown is supported
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