Windows QPA: use make_unique instead of QSP+raw new+memset

A minimal change here would've been just to use value initialization
instead of default initialization. But just go for the kill -- stop
using QScopedPointer.

Change-Id: Ie427a44d13987c2b4a2c881c350df04e935df9d8
Reviewed-by: Yuhang Zhao <yuhangzhao@deepin.org>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
bb10
Giuseppe D'Angelo 2023-01-05 03:17:55 +01:00
parent c155216917
commit 3d8e02152a
1 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,8 @@
#include <QtGui/qcursor.h>
#include <QtCore/qdebug.h>
#include <QtCore/qscopedpointer.h>
#include <memory>
#include <windowsx.h>
@ -577,15 +578,14 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
const QRect screenGeometry = screen->geometry();
const int winTouchPointCount = int(msg.wParam);
QScopedArrayPointer<TOUCHINPUT> winTouchInputs(new TOUCHINPUT[winTouchPointCount]);
memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * size_t(winTouchPointCount));
const auto winTouchInputs = std::make_unique<TOUCHINPUT[]>(winTouchPointCount);
QTouchPointList touchPoints;
touchPoints.reserve(winTouchPointCount);
QEventPoint::States allStates;
GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(msg.lParam),
UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT));
UINT(msg.wParam), winTouchInputs.get(), sizeof(TOUCHINPUT));
for (int i = 0; i < winTouchPointCount; ++i) {
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);