winrt platform plugin: Fix clang warnings

Fixed warnings:
  - missing override specifier
  - 0 as nullptr constant
  - implicit change of signedness
  - non portable path to header file

Change-Id: I6977bc561176ac7804ac01325b84c15ba849bbf2
Reviewed-by: Miguel Costa <miguel.costa@qt.io>
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Oliver Wolff 2018-09-05 14:48:30 +02:00
parent e5b4e7a9ed
commit 7421a0e882
24 changed files with 72 additions and 89 deletions

View File

@ -58,7 +58,7 @@ QPlatformIntegration *QWinRTIntegrationPlugin::create(const QString& system, con
if (!system.compare(QLatin1String("winrt"), Qt::CaseInsensitive))
return QWinRTIntegration::create();
return 0;
return nullptr;
}
QT_END_NAMESPACE

View File

@ -54,7 +54,7 @@ class QWinRTBackingStore : public QPlatformBackingStore
{
public:
explicit QWinRTBackingStore(QWindow *window);
~QWinRTBackingStore();
~QWinRTBackingStore() override;
QPaintDevice *paintDevice() override;
void beginPaint(const QRegion &) override;
void endPaint() override;

View File

@ -70,10 +70,6 @@ QWinRTCanvas::QWinRTCanvas(const std::function<QWindow*()> &delegateWindow)
delegate = delegateWindow;
}
QWinRTCanvas::~QWinRTCanvas()
{
}
HRESULT STDMETHODCALLTYPE QWinRTCanvas::QueryInterface(REFIID iid, LPVOID *iface)
{
if (!iface)

View File

@ -54,7 +54,7 @@ class QWinRTCanvas:
{
public:
QWinRTCanvas(const std::function<QWindow*()> &delegateWindow);
virtual ~QWinRTCanvas();
~QWinRTCanvas() override = default;
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *iface) override;
HRESULT STDMETHODCALLTYPE GetIids(ULONG *iidCount, IID **iids) override;

View File

@ -99,7 +99,7 @@ QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode)
quint32 size;
const wchar_t *textStr = result.GetRawBuffer(&size);
QString text = QString::fromWCharArray(textStr, size);
QString text = QString::fromWCharArray(textStr, int(size));
text.replace(QLatin1String("\r\n"), QLatin1String("\n"));
if (m_mimeData) {
@ -161,7 +161,8 @@ void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
&package);
const QString nativeString = convertToWindowsLineEnding(text);
HStringReference textRef(reinterpret_cast<LPCWSTR>(nativeString.utf16()), nativeString.length());
HStringReference textRef(reinterpret_cast<LPCWSTR>(nativeString.utf16()),
uint(nativeString.length()));
hr = package->SetText(textRef.Get());
RETURN_HR_IF_FAILED("Could not set text to clipboard data package.");

View File

@ -78,10 +78,6 @@ QWinRTCursor::QWinRTCursor()
Q_ASSERT_SUCCEEDED(hr);
}
QWinRTCursor::~QWinRTCursor()
{
}
#ifndef QT_NO_CURSOR
void QWinRTCursor::changeCursor(QCursor *windowCursor, QWindow *window)
{
@ -183,9 +179,9 @@ QPoint QWinRTCursor::pos() const
return hr;
});
Q_ASSERT_SUCCEEDED(hr);
QPoint position = QPoint(point.X, point.Y);
QPoint position = QPoint(int(point.X), int(point.Y));
// If no cursor get_PointerPosition returns SHRT_MIN for x and y
if (position.x() == SHRT_MIN && position.y() == SHRT_MIN || FAILED(hr))
if ((position.x() == SHRT_MIN && position.y() == SHRT_MIN) || FAILED(hr))
return QPointF(Q_INFINITY, Q_INFINITY).toPoint();
position.rx() -= bounds.X;
position.ry() -= bounds.Y;
@ -211,7 +207,8 @@ void QWinRTCursor::setPos(const QPoint &pos)
Point mousePos;
hr = coreWindow->get_PointerPosition(&mousePos);
RETURN_HR_IF_FAILED("Failed to obtain mouse position.");
const Point p = {FLOAT(scaledPos.x() + bounds.X), FLOAT(scaledPos.y() + bounds.Y)};
const Point p = { FLOAT(scaledPos.x()) + bounds.X,
FLOAT(scaledPos.y()) + bounds.Y };
const bool wasInWindow = qIsPointInRect(mousePos, bounds);
const bool willBeInWindow = qIsPointInRect(p, bounds);
if (wasInWindow && willBeInWindow)

View File

@ -49,7 +49,7 @@ class QWinRTCursor : public QPlatformCursor
{
public:
explicit QWinRTCursor();
~QWinRTCursor();
~QWinRTCursor() override = default;
#ifndef QT_NO_CURSOR
void changeCursor(QCursor * windowCursor, QWindow *window) override;
#endif

View File

@ -81,7 +81,7 @@ ComPtr<IBuffer> createIBufferFromData(const char *data, qint32 size)
}
ComPtr<IBuffer> buffer;
const UINT32 length = size;
const UINT32 length = UINT32(size);
hr = bufferFactory->Create(length, &buffer);
Q_ASSERT_SUCCEEDED(hr);
hr = buffer->put_Length(length);
@ -118,13 +118,13 @@ inline QString hStringToQString(const HString &hString)
{
quint32 l;
const wchar_t *raw = hString.GetRawBuffer(&l);
return (QString::fromWCharArray(raw, l));
return (QString::fromWCharArray(raw, int(l)));
}
inline HString qStringToHString(const QString &qString)
{
HString h;
h.Set(reinterpret_cast<const wchar_t*>(qString.utf16()), qString.size());
h.Set(reinterpret_cast<const wchar_t*>(qString.utf16()), uint(qString.size()));
return h;
}
@ -184,10 +184,6 @@ QWinRTInternalMimeData::QWinRTInternalMimeData()
}
}
QWinRTInternalMimeData::~QWinRTInternalMimeData()
{
}
bool QWinRTInternalMimeData::hasFormat_sys(const QString &mimetype) const
{
qCDebug(lcQpaMime) << __FUNCTION__ << mimetype;
@ -311,7 +307,7 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari
ComPtr<IAsyncOperation<IInspectable*>> op;
ComPtr<IInspectable> res;
HString type;
type.Set(reinterpret_cast<const wchar_t*>(mimetype.utf16()), mimetype.size());
type.Set(reinterpret_cast<const wchar_t*>(mimetype.utf16()), uint(mimetype.size()));
hr = dataView->GetDataAsync(type.Get(), &op);
RETURN_OK_IF_FAILED("Could not query custom drag data.");
hr = QWinRTFunctions::await(op, res.GetAddressOf());
@ -434,7 +430,7 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari
IID_PPV_ARGS(&bufferFactory));
Q_ASSERT_SUCCEEDED(hr);
UINT32 length = qBound(quint64(0), quint64(size), quint64(UINT_MAX));
UINT32 length = UINT32(qBound(quint64(0), quint64(size), quint64(UINT_MAX)));
ComPtr<IBuffer> buffer;
hr = bufferFactory->Create(length, &buffer);
Q_ASSERT_SUCCEEDED(hr);
@ -452,7 +448,7 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari
byte *bytes;
hr = byteArrayAccess->Buffer(&bytes);
QByteArray array((char *)bytes, length);
QByteArray array((char *)bytes, int(length));
result.setValue(array);
return S_OK;
}
@ -559,7 +555,7 @@ extern ComPtr<ABI::Windows::UI::Input::IPointerPoint> qt_winrt_lastPointerPoint;
QWinRTDrag::QWinRTDrag()
: QPlatformDrag()
, m_dragTarget(0)
, m_dragTarget(nullptr)
{
qCDebug(lcQpaMime) << __FUNCTION__;
m_enter = new Q_INST_DRAGHANDLER(Enter);
@ -612,7 +608,7 @@ Qt::DropAction QWinRTDrag::drag(QDrag *drag)
ComPtr<IAsyncOperation<ABI::Windows::ApplicationModel::DataTransfer::DataPackageOperation>> op;
EventRegistrationToken startingToken;
hr = QEventDispatcherWinRT::runOnXamlThread([drag, &op, &hr, elem3, &startingToken, this]() {
hr = QEventDispatcherWinRT::runOnXamlThread([drag, &op, &hr, elem3, &startingToken]() {
hr = elem3->put_CanDrag(true);
Q_ASSERT_SUCCEEDED(hr);
@ -660,7 +656,8 @@ Qt::DropAction QWinRTDrag::drag(QDrag *drag)
const QImage image = image2.convertToFormat(QImage::Format_ARGB32);
if (!image.isNull()) {
// Create IBuffer containing image
ComPtr<IBuffer> imageBuffer = createIBufferFromData(reinterpret_cast<const char*>(image.bits()), image.byteCount());
ComPtr<IBuffer> imageBuffer
= createIBufferFromData(reinterpret_cast<const char*>(image.bits()), int(image.sizeInBytes()));
ComPtr<ISoftwareBitmapFactory> bitmapFactory;
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Graphics_Imaging_SoftwareBitmap).Get(),
@ -697,7 +694,7 @@ Qt::DropAction QWinRTDrag::drag(QDrag *drag)
hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Storage_Streams_InMemoryRandomAccessStream).Get(), &ras);
Q_ASSERT_SUCCEEDED(hr);
hr = ras->put_Size(data.size());
hr = ras->put_Size(UINT64(data.size()));
ComPtr<IOutputStream> outputStream;
hr = ras->GetOutputStreamAt(0, &outputStream);
Q_ASSERT_SUCCEEDED(hr);
@ -802,7 +799,7 @@ void QWinRTDrag::handleNativeDragEvent(IInspectable *sender, ABI::Windows::UI::X
Point relativePoint;
hr = e->GetPosition(m_ui.Get(), &relativePoint);
RETURN_VOID_IF_FAILED("Could not query drag position.");
const QPoint p(relativePoint.X, relativePoint.Y);
const QPoint p(int(relativePoint.X), int(relativePoint.Y));
ComPtr<IDragEventArgs2> e2;
hr = e->QueryInterface(IID_PPV_ARGS(&e2));

View File

@ -77,7 +77,7 @@ class QWinRTInternalMimeData;
class QWinRTInternalMimeData : public QInternalMimeData {
public:
QWinRTInternalMimeData();
virtual ~QWinRTInternalMimeData();
~QWinRTInternalMimeData() override = default;
bool hasFormat_sys(const QString &mimetype) const override;
QStringList formats_sys() const override;
@ -92,7 +92,7 @@ private:
class QWinRTDrag : public QPlatformDrag {
public:
QWinRTDrag();
virtual ~QWinRTDrag();
~QWinRTDrag() override;
static QWinRTDrag *instance();
Qt::DropAction drag(QDrag *) override;

View File

@ -50,7 +50,7 @@ class QWinRTEGLContext : public QPlatformOpenGLContext
{
public:
explicit QWinRTEGLContext(QOpenGLContext *context);
~QWinRTEGLContext();
~QWinRTEGLContext() override;
void initialize() override;

View File

@ -48,7 +48,7 @@ class QWinRTEventDispatcher : public QEventDispatcherWinRT
{
Q_OBJECT
public:
explicit QWinRTEventDispatcher(QObject *parent = 0);
explicit QWinRTEventDispatcher(QObject *parent = nullptr);
protected:
bool hasPendingEvents() override;

View File

@ -51,7 +51,7 @@
#include <wrl.h>
#include <windows.foundation.h>
#include <windows.storage.pickers.h>
#include <Windows.ApplicationModel.activation.h>
#include <Windows.Applicationmodel.Activation.h>
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
@ -73,12 +73,12 @@ class WindowsStringVector : public RuntimeClass<IVector<HSTRING>>
public:
HRESULT __stdcall GetAt(quint32 index, HSTRING *item)
{
*item = impl.at(index);
*item = impl.at(int(index));
return S_OK;
}
HRESULT __stdcall get_Size(quint32 *size)
{
*size = impl.size();
*size = quint32(impl.size());
return S_OK;
}
HRESULT __stdcall GetView(IVectorView<HSTRING> **view)
@ -108,7 +108,7 @@ public:
HRESULT hr = WindowsDuplicateString(item, &newItem);
if (FAILED(hr))
return hr;
impl[index] = newItem;
impl[int(index)] = newItem;
return S_OK;
}
HRESULT __stdcall InsertAt(quint32 index, HSTRING item)
@ -117,12 +117,12 @@ public:
HRESULT hr = WindowsDuplicateString(item, &newItem);
if (FAILED(hr))
return hr;
impl.insert(index, newItem);
impl.insert(int(index), newItem);
return S_OK;
}
HRESULT __stdcall RemoveAt(quint32 index)
{
WindowsDeleteString(impl.takeAt(index));
WindowsDeleteString(impl.takeAt(int(index)));
return S_OK;
}
HRESULT __stdcall Append(HSTRING item)
@ -164,7 +164,7 @@ static bool initializePicker(HSTRING runtimeId, T **picker, const QSharedPointer
if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)) {
const QString labelText = options->labelText(QFileDialogOptions::Accept);
HStringReference labelTextRef(reinterpret_cast<const wchar_t *>(labelText.utf16()),
labelText.length());
uint(labelText.length()));
hr = (*picker)->put_CommitButtonText(labelTextRef.Get());
RETURN_FALSE_IF_FAILED("Failed to set commit button text");
}
@ -188,7 +188,7 @@ static bool initializeOpenPickerOptions(T *picker, const QSharedPointer<QFileDia
// Remove leading star
const int offset = (filter.length() > 1 && filter.startsWith(QLatin1Char('*'))) ? 1 : 0;
HStringReference filterRef(reinterpret_cast<const wchar_t *>(filter.utf16() + offset),
filter.length() - offset);
uint(filter.length() - offset));
hr = filters->Append(filterRef.Get());
if (FAILED(hr)) {
qWarning("Failed to add named file filter \"%s\": %s",
@ -290,16 +290,12 @@ QWinRTFileDialogHelper::QWinRTFileDialogHelper()
d->shown = false;
}
QWinRTFileDialogHelper::~QWinRTFileDialogHelper()
{
}
void QWinRTFileDialogHelper::exec()
{
Q_D(QWinRTFileDialogHelper);
if (!d->shown)
show(Qt::Dialog, Qt::ApplicationModal, 0);
show(Qt::Dialog, Qt::ApplicationModal, nullptr);
d->loop.exec();
}
@ -369,7 +365,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
// Remove leading star
const int starOffset = (filter.length() > 1 && filter.startsWith(QLatin1Char('*'))) ? 1 : 0;
HStringReference filterRef(reinterpret_cast<const wchar_t *>(filter.utf16() + starOffset),
filter.length() - starOffset);
uint(filter.length() - starOffset));
hr = entry->Append(filterRef.Get());
if (FAILED(hr)) {
qWarning("Failed to add named file filter \"%s\": %s",
@ -379,7 +375,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
const int offset = namedFilter.indexOf(QLatin1String(" ("));
const QString filterTitle = namedFilter.mid(0, offset);
HStringReference namedFilterRef(reinterpret_cast<const wchar_t *>(filterTitle.utf16()),
filterTitle.length());
uint(filterTitle.length()));
boolean replaced;
hr = choices->Insert(namedFilterRef.Get(), entry.Get(), &replaced);
// Only print a warning as * or *.* is not a valid choice on Windows 10
@ -396,7 +392,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
if (!suffix.startsWith(QLatin1Char('.')))
suffix.prepend(QLatin1Char('.'));
HStringReference nativeSuffix(reinterpret_cast<const wchar_t *>(suffix.utf16()),
suffix.length());
uint(suffix.length()));
hr = picker->put_DefaultFileExtension(nativeSuffix.Get());
RETURN_FALSE_IF_FAILED_WITH_ARGS("Failed to set default file extension \"%s\"", qPrintable(suffix));
}
@ -404,7 +400,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
const QString suggestedName = QFileInfo(d->saveFileName.toLocalFile()).fileName();
if (!suggestedName.isEmpty()) {
HStringReference nativeSuggestedName(reinterpret_cast<const wchar_t *>(suggestedName.utf16()),
suggestedName.length());
uint(suggestedName.length()));
hr = picker->put_SuggestedFileName(nativeSuggestedName.Get());
RETURN_FALSE_IF_FAILED("Failed to set suggested file name");
}

View File

@ -70,7 +70,7 @@ class QWinRTFileDialogHelper : public QPlatformFileDialogHelper
Q_OBJECT
public:
explicit QWinRTFileDialogHelper();
~QWinRTFileDialogHelper();
~QWinRTFileDialogHelper() override = default;
void exec() override;
bool show(Qt::WindowFlags, Qt::WindowModality, QWindow *) override;

View File

@ -122,10 +122,6 @@ QWinRTFileEngineHandler::QWinRTFileEngineHandler()
{
}
QWinRTFileEngineHandler::~QWinRTFileEngineHandler()
{
}
void QWinRTFileEngineHandler::registerFile(const QString &fileName, IStorageItem *file)
{
handlerInstance->d_func()->files.insert(QDir::cleanPath(fileName), file);
@ -168,7 +164,7 @@ static HRESULT getDestinationFolder(const QString &fileName, const QString &newF
const QString newFilePath = QDir::toNativeSeparators(newFileInfo.absolutePath());
HStringReference nativeNewFilePath(reinterpret_cast<LPCWSTR>(newFilePath.utf16()),
newFilePath.length());
uint(newFilePath.length()));
hr = folderFactory->GetFolderFromPathAsync(nativeNewFilePath.Get(), &op);
}
if (FAILED(hr))
@ -181,10 +177,6 @@ QWinRTFileEngine::QWinRTFileEngine(const QString &fileName, IStorageItem *file)
{
}
QWinRTFileEngine::~QWinRTFileEngine()
{
}
bool QWinRTFileEngine::open(QIODevice::OpenMode openMode)
{
Q_D(QWinRTFileEngine);
@ -278,7 +270,7 @@ bool QWinRTFileEngine::seek(qint64 pos)
if (!d->stream)
return false;
HRESULT hr = d->stream->Seek(pos);
HRESULT hr = d->stream->Seek(UINT64(pos));
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::PositionError, false);
d->pos = pos;
return SUCCEEDED(hr);
@ -311,7 +303,8 @@ bool QWinRTFileEngine::copy(const QString &newName)
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::CopyError, false);
const QString destinationName = QFileInfo(newName).fileName();
HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), destinationName.length());
HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()),
uint(destinationName.length()));
ComPtr<IAsyncOperation<StorageFile *>> op;
hr = file->CopyOverloadDefaultOptions(destinationFolder.Get(), nativeDestinationName.Get(), &op);
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::CopyError, false);
@ -332,7 +325,8 @@ bool QWinRTFileEngine::rename(const QString &newName)
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false);
const QString destinationName = QFileInfo(newName).fileName();
HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), destinationName.length());
HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()),
uint(destinationName.length()));
ComPtr<IAsyncAction> op;
hr = d->file->RenameAsyncOverloadDefaultOptions(nativeDestinationName.Get(), &op);
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false);
@ -349,7 +343,8 @@ bool QWinRTFileEngine::renameOverwrite(const QString &newName)
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false);
const QString destinationName = QFileInfo(newName).fileName();
HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), destinationName.length());
HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()),
uint(destinationName.length()));
ComPtr<IAsyncAction> op;
hr = d->file->RenameAsync(nativeDestinationName.Get(), NameCollisionOption_ReplaceExisting, &op);
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false);
@ -451,7 +446,7 @@ qint64 QWinRTFileEngine::read(char *data, qint64 maxlen)
HRESULT hr = d->stream.As(&stream);
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1);
UINT32 length = qBound(quint64(0), quint64(maxlen), quint64(UINT_MAX));
UINT32 length = UINT32(qBound(quint64(0), quint64(maxlen), quint64(UINT32_MAX)));
ComPtr<IBuffer> buffer;
hr = d->bufferFactory->Create(length, &buffer);
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1);
@ -494,7 +489,7 @@ qint64 QWinRTFileEngine::write(const char *data, qint64 maxlen)
HRESULT hr = d->stream.As(&stream);
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::WriteError, -1);
UINT32 length = qBound(quint64(0), quint64(maxlen), quint64(UINT_MAX));
UINT32 length = UINT32(qBound(quint64(0), quint64(maxlen), quint64(UINT_MAX)));
ComPtr<IBuffer> buffer;
hr = d->bufferFactory->Create(length, &buffer);
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::WriteError, -1);

View File

@ -57,7 +57,7 @@ class QWinRTFileEngineHandler : public QAbstractFileEngineHandler
{
public:
QWinRTFileEngineHandler();
~QWinRTFileEngineHandler();
~QWinRTFileEngineHandler() override = default;
QAbstractFileEngine *create(const QString &fileName) const override;
static void registerFile(const QString &fileName, ABI::Windows::Storage::IStorageItem *file);
@ -73,7 +73,7 @@ class QWinRTFileEngine : public QAbstractFileEngine
{
public:
QWinRTFileEngine(const QString &fileName, ABI::Windows::Storage::IStorageItem *file);
~QWinRTFileEngine();
~QWinRTFileEngine() override = default;
bool open(QIODevice::OpenMode openMode) override;
bool close() override;

View File

@ -64,8 +64,8 @@ inline QRectF getInputPaneRect(ComPtr<IInputPane> pane, qreal scaleFactor)
{
Rect rect;
pane->get_OccludedRect(&rect);
return QRectF(qRound(rect.X * scaleFactor), qRound(rect.Y * scaleFactor),
qRound(rect.Width * scaleFactor), qRound(rect.Height * scaleFactor));
return QRectF(qRound(qreal(rect.X) * scaleFactor), qRound(qreal(rect.Y) * scaleFactor),
qRound(qreal(rect.Width) * scaleFactor), qRound(qreal(rect.Height) * scaleFactor));
}
/*!

View File

@ -75,7 +75,7 @@ class QWinRTIntegration : public QPlatformIntegration
private:
explicit QWinRTIntegration();
public:
~QWinRTIntegration();
~QWinRTIntegration() override;
static QWinRTIntegration *create()
{

View File

@ -99,7 +99,7 @@ void QWinRTMessageDialogHelper::exec()
Q_D(QWinRTMessageDialogHelper);
if (!d->shown)
show(Qt::Dialog, Qt::ApplicationModal, 0);
show(Qt::Dialog, Qt::ApplicationModal, nullptr);
d->loop.exec();
}
@ -134,9 +134,11 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa
RETURN_FALSE_IF_FAILED("Failed to create command factory");
ComPtr<IMessageDialog> dialog;
HStringReference nativeText(reinterpret_cast<LPCWSTR>(text.utf16()), text.size());
HStringReference nativeText(reinterpret_cast<LPCWSTR>(text.utf16()),
uint(text.size()));
if (!title.isEmpty()) {
HStringReference nativeTitle(reinterpret_cast<LPCWSTR>(title.utf16()), title.size());
HStringReference nativeTitle(reinterpret_cast<LPCWSTR>(title.utf16()),
uint(title.size()));
hr = dialogFactory->CreateWithTitle(nativeText.Get(), nativeTitle.Get(), &dialog);
RETURN_FALSE_IF_FAILED("Failed to create dialog with title");
} else {
@ -162,7 +164,8 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa
continue;
// Add native command
const QString label = d->theme->standardButtonText(i);
HStringReference nativeLabel(reinterpret_cast<LPCWSTR>(label.utf16()), label.size());
HStringReference nativeLabel(reinterpret_cast<LPCWSTR>(label.utf16()),
uint(label.size()));
ComPtr<IUICommand> command;
hr = commandFactory->Create(nativeLabel.Get(), &command);
RETURN_HR_IF_FAILED("Failed to create message box command");

View File

@ -67,7 +67,7 @@ class QWinRTMessageDialogHelper : public QPlatformMessageDialogHelper
Q_OBJECT
public:
explicit QWinRTMessageDialogHelper(const QWinRTTheme *theme);
~QWinRTMessageDialogHelper();
~QWinRTMessageDialogHelper() override;
void exec() override;
bool show(Qt::WindowFlags windowFlags,

View File

@ -89,7 +89,7 @@ class QWinRTScreen : public QPlatformScreen
{
public:
explicit QWinRTScreen();
~QWinRTScreen();
~QWinRTScreen() override;
QRect geometry() const override;
QRect availableGeometry() const override;

View File

@ -83,17 +83,14 @@ QWinRTServices::QWinRTServices()
Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr)));
}
QWinRTServices::~QWinRTServices()
{
}
bool QWinRTServices::openUrl(const QUrl &url)
{
Q_D(QWinRTServices);
ComPtr<IUriRuntimeClass> uri;
QString urlString = url.toString();
HStringReference uriString(reinterpret_cast<LPCWSTR>(urlString.utf16()), urlString.length());
HStringReference uriString(reinterpret_cast<LPCWSTR>(urlString.utf16()),
uint(urlString.length()));
HRESULT hr = d->uriFactory->CreateUri(uriString.Get(), &uri);
RETURN_FALSE_IF_FAILED("Failed to create URI from QUrl.");
@ -122,7 +119,8 @@ bool QWinRTServices::openDocument(const QUrl &url)
}
if (!file) {
const QString pathString = QDir::toNativeSeparators(url.toLocalFile());
HStringReference path(reinterpret_cast<LPCWSTR>(pathString.utf16()), pathString.length());
HStringReference path(reinterpret_cast<LPCWSTR>(pathString.utf16()),
uint(pathString.length()));
ComPtr<IAsyncOperation<StorageFile *>> op;
hr = d->fileFactory->GetFileFromPathAsync(path.Get(), &op);
RETURN_FALSE_IF_FAILED("Failed to initialize file URI.");

View File

@ -50,7 +50,7 @@ class QWinRTServices : public QPlatformServices
{
public:
explicit QWinRTServices();
~QWinRTServices();
~QWinRTServices() override = default;
bool openUrl(const QUrl &url) override;
bool openDocument(const QUrl &url) override;

View File

@ -126,7 +126,7 @@ QWinRTWindow::QWinRTWindow(QWindow *window)
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_Xaml_Controls_Canvas).Get(),
IID_PPV_ARGS(&d->canvas));
Q_ASSERT_SUCCEEDED(hr);
hr = QEventDispatcherWinRT::runOnXamlThread([this, d]() {
hr = QEventDispatcherWinRT::runOnXamlThread([d]() {
// Create a new swapchain and place it inside the canvas
HRESULT hr;
hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_UI_Xaml_Controls_SwapChainPanel).Get(),

View File

@ -54,7 +54,7 @@ class QWinRTWindow : public QPlatformWindow
{
public:
QWinRTWindow(QWindow *window);
~QWinRTWindow();
~QWinRTWindow() override;
QSurfaceFormat format() const override;
bool isActive() const override;