Cocoa: avoid a crash in QCocoaDrag

NSEvent needs to be copied.

Reference:
http://lists.apple.com/archives/cocoa-dev/2007/Dec/msg00678.html

Task-number: QTBUG-33533
Change-Id: I73709545573e59aab6875a8c3dd903cb171e858f
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
bb10
Liang Qi 2013-11-28 14:42:56 +01:00 committed by The Qt Project
parent ad684ff2a7
commit d55db6dd53
2 changed files with 8 additions and 1 deletions

View File

@ -55,6 +55,7 @@ class QCocoaDrag : public QPlatformDrag
{
public:
QCocoaDrag();
virtual ~QCocoaDrag();
virtual QMimeData *platformDropData();
virtual Qt::DropAction drag(QDrag *m_drag);

View File

@ -53,9 +53,15 @@ QCocoaDrag::QCocoaDrag() :
m_lastView = 0;
}
QCocoaDrag::~QCocoaDrag()
{
[m_lastEvent release];
}
void QCocoaDrag::setLastMouseEvent(NSEvent *event, NSView *view)
{
m_lastEvent = event;
[m_lastEvent release];
m_lastEvent = [event copy];
m_lastView = view;
}