Commit d26ab7cf authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix potential crash

parent 0e5e650e
...@@ -284,18 +284,15 @@ QString MessageItem::annotation() const ...@@ -284,18 +284,15 @@ QString MessageItem::annotation() const
return QString(); return QString();
} }
void MessageItem::editAnnotation() void MessageItem::editAnnotation(QWidget *parent)
{ {
Q_D(MessageItem); Q_D(MessageItem);
if (d->mAnnotationDialog.data()) { QPointer<PimCommon::AnnotationEditDialog> mAnnotationDialog = new PimCommon::AnnotationEditDialog(d->mAkonadiItem, parent);
return;
}
d->mAnnotationDialog = new PimCommon::AnnotationEditDialog(d->mAkonadiItem);
d->mAnnotationDialog.data()->setAttribute(Qt::WA_DeleteOnClose);
//FIXME make async //FIXME make async
if (d->mAnnotationDialog.data()->exec()) { if (mAnnotationDialog->exec()) {
// invalidate the cached mHasAnnotation value // invalidate the cached mHasAnnotation value
} }
delete mAnnotationDialog;
} }
const MessageItem::Tag *MessageItemPrivate::findTagInternal(const QString &szTagId) const const MessageItem::Tag *MessageItemPrivate::findTagInternal(const QString &szTagId) const
......
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
QString annotation() const; QString annotation() const;
/// Shows a dialog to edit or delete the annotation /// Shows a dialog to edit or delete the annotation
void editAnnotation(); void editAnnotation(QWidget *parent);
/** /**
* Returns Tag associated to this message that has the specified id or 0 * Returns Tag associated to this message that has the specified id or 0
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <Monitor> #include <Monitor>
#include <Tag> #include <Tag>
#include <KJob> #include <KJob>
#include <QWeakPointer> #include <QPointer>
#include <QCache> #include <QCache>
namespace MessageList namespace MessageList
...@@ -72,7 +72,6 @@ public: ...@@ -72,7 +72,6 @@ public:
QByteArray mReferencesIdMD5; ///< set only if we're doing threading QByteArray mReferencesIdMD5; ///< set only if we're doing threading
QByteArray mStrippedSubjectMD5; ///< set only if we're doing threading QByteArray mStrippedSubjectMD5; ///< set only if we're doing threading
Akonadi::Item mAkonadiItem; Akonadi::Item mAkonadiItem;
QWeakPointer<PimCommon::AnnotationEditDialog> mAnnotationDialog;
MessageItem::ThreadingStatus mThreadingStatus : 4; MessageItem::ThreadingStatus mThreadingStatus : 4;
MessageItem::EncryptionState mEncryptionState : 4; MessageItem::EncryptionState mEncryptionState : 4;
MessageItem::SignatureState mSignatureState : 4; MessageItem::SignatureState mSignatureState : 4;
......
...@@ -2091,7 +2091,7 @@ void View::mousePressEvent(QMouseEvent *e) ...@@ -2091,7 +2091,7 @@ void View::mousePressEvent(QMouseEvent *e)
switch (d->mDelegate->hitContentItem()->type()) { switch (d->mDelegate->hitContentItem()->type()) {
case Theme::ContentItem::AnnotationIcon: case Theme::ContentItem::AnnotationIcon:
static_cast< MessageItem * >(it)->editAnnotation(); static_cast< MessageItem * >(it)->editAnnotation(this);
return; // don't select the item return; // don't select the item
break; break;
case Theme::ContentItem::ActionItemStateIcon: case Theme::ContentItem::ActionItemStateIcon:
......
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