Use a smart pointer for QWasmDrag::m_mimeData

Change-Id: I10e27a92d37e5bf131c7c0f22860a957d1f1592d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Mikolaj Boc 2022-12-19 17:22:11 +01:00
parent ada9c2f8f8
commit 3e78331dac
2 changed files with 5 additions and 11 deletions

View File

@ -61,9 +61,7 @@ static void dropEvent(val event)
reinterpret_cast<QWasmScreen*>(event["target"]["data-qtdropcontext"].as<quintptr>());
wasmDrag->m_mouseDropPoint = QPoint(event["x"].as<int>(), event["y"].as<int>());
if (wasmDrag->m_mimeData)
delete wasmDrag->m_mimeData;
wasmDrag->m_mimeData = new QMimeData;
wasmDrag->m_mimeData = std::make_unique<QMimeData>();
wasmDrag->m_qButton = MouseEvent::buttonFromWeb(event["button"].as<int>());
wasmDrag->m_keyModifiers = Qt::NoModifier;
@ -152,11 +150,7 @@ QWasmDrag::QWasmDrag()
init();
}
QWasmDrag::~QWasmDrag()
{
if (m_mimeData)
delete m_mimeData;
}
QWasmDrag::~QWasmDrag() = default;
void QWasmDrag::init()
{
@ -182,7 +176,7 @@ void QWasmDrag::qWasmDrop()
// start drag enter
QWindowSystemInterface::handleDrag(thisDrag->m_wasmScreen->topLevelAt(thisDrag->m_mouseDropPoint),
thisDrag->m_mimeData,
thisDrag->m_mimeData.get(),
thisDrag->m_mouseDropPoint,
thisDrag->m_dropActions,
thisDrag->m_qButton,
@ -190,7 +184,7 @@ void QWasmDrag::qWasmDrop()
// drag drop
QWindowSystemInterface::handleDrop(thisDrag->m_wasmScreen->topLevelAt(thisDrag->m_mouseDropPoint),
thisDrag->m_mimeData,
thisDrag->m_mimeData.get(),
thisDrag->m_mouseDropPoint,
thisDrag->m_dropActions,
thisDrag->m_qButton,

View File

@ -30,7 +30,7 @@ public:
Qt::DropActions m_dropActions;
QWasmScreen *m_wasmScreen = nullptr;
int m_mimeTypesCount = 0;
QMimeData *m_mimeData = nullptr;
std::unique_ptr<QMimeData> m_mimeData;
void qWasmDrop();
private: