diff --git a/src/plugins/platforms/wasm/qwasmdrag.cpp b/src/plugins/platforms/wasm/qwasmdrag.cpp index c2b50e43560..6deb9e02568 100644 --- a/src/plugins/platforms/wasm/qwasmdrag.cpp +++ b/src/plugins/platforms/wasm/qwasmdrag.cpp @@ -61,9 +61,7 @@ static void dropEvent(val event) reinterpret_cast(event["target"]["data-qtdropcontext"].as()); wasmDrag->m_mouseDropPoint = QPoint(event["x"].as(), event["y"].as()); - if (wasmDrag->m_mimeData) - delete wasmDrag->m_mimeData; - wasmDrag->m_mimeData = new QMimeData; + wasmDrag->m_mimeData = std::make_unique(); wasmDrag->m_qButton = MouseEvent::buttonFromWeb(event["button"].as()); 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, diff --git a/src/plugins/platforms/wasm/qwasmdrag.h b/src/plugins/platforms/wasm/qwasmdrag.h index 6358b415c3d..3da8b308635 100644 --- a/src/plugins/platforms/wasm/qwasmdrag.h +++ b/src/plugins/platforms/wasm/qwasmdrag.h @@ -30,7 +30,7 @@ public: Qt::DropActions m_dropActions; QWasmScreen *m_wasmScreen = nullptr; int m_mimeTypesCount = 0; - QMimeData *m_mimeData = nullptr; + std::unique_ptr m_mimeData; void qWasmDrop(); private: