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 9d5da010 authored by Laurent Montel's avatar Laurent Montel 😁

Fix potential crash

parent 0f54cdba
......@@ -77,15 +77,15 @@ void CreateNewContactJob::slotCollectionsFetched(KJob *job)
}
}
if (canCreateItemCollections.isEmpty()) {
Akonadi::AgentTypeDialog dlg(mParentWidget);
dlg.setWindowTitle(i18n("Add to 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();
QPointer<Akonadi::AgentTypeDialog> dlg = new Akonadi::AgentTypeDialog(mParentWidget);
dlg->setWindowTitle(i18n("Add to 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();
delete dlg;
if (agentType.isValid()) {
Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(agentType, this);
connect(job, &Akonadi::AgentInstanceCreateJob::result, this, &CreateNewContactJob::slotResourceCreationDone);
......@@ -98,6 +98,7 @@ void CreateNewContactJob::slotCollectionsFetched(KJob *job)
return;
}
} else { //dialog canceled => return error and finish job
delete dlg;
setError(UserDefinedError);
emitResult();
return;
......
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