From 3627d8b171379e4f0d3b52d33fcce4767282f1d9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Jul 2015 11:02:41 +0200 Subject: Windows/QClipboard: Fix crash in debug output of QMimeData. Rewrite QDebug operator<<(QDebug d, const QMimeData &mimeData) to take a pointer and handle 0 values. Change the formatting to the style commonly used in Qt. Make it static as it is not used anywhere else. Task-number: QTBUG-47393 Change-Id: I78174e10b75769bf4acd33a894acc0a51e525c39 Reviewed-by: Joerg Bornemann --- .../platforms/windows/qwindowsclipboard.cpp | 37 ++++++++++++---------- .../platforms/windows/qwindowsinternalmimedata.h | 2 -- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 4cea845c36..925427ac30 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -69,25 +69,28 @@ static const char formatTextHtmlC[] = "text/html"; \ingroup qt-lighthouse-win */ -QDebug operator<<(QDebug d, const QMimeData &m) +static QDebug operator<<(QDebug d, const QMimeData *mimeData) { QDebugStateSaver saver(d); d.nospace(); - const QStringList formats = m.formats(); - d << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n' - << " Text=" << m.hasText() << " HTML=" << m.hasHtml() - << " Color=" << m.hasColor() << " Image=" << m.hasImage() - << " URLs=" << m.hasUrls() << '\n'; - if (m.hasText()) - d << " Text: '" << m.text() << "'\n"; - if (m.hasHtml()) - d << " HTML: '" << m.html() << "'\n"; - if (m.hasColor()) - d << " Color: " << qvariant_cast(m.colorData()) << '\n'; - if (m.hasImage()) - d << " Image: " << qvariant_cast(m.imageData()).size() << '\n'; - if (m.hasUrls()) - d << " URLs: " << m.urls() << '\n'; + d << "QMimeData("; + if (mimeData) { + const QStringList formats = mimeData->formats(); + d << "formats=" << formats.join(QStringLiteral(", ")); + if (mimeData->hasText()) + d << ", text=" << mimeData->text(); + if (mimeData->hasHtml()) + d << ", html=" << mimeData->html(); + if (mimeData->hasColor()) + d << ", colorData=" << qvariant_cast(mimeData->colorData()); + if (mimeData->hasImage()) + d << ", imageData=" << qvariant_cast(mimeData->imageData()); + if (mimeData->hasUrls()) + d << ", urls=" << mimeData->urls(); + } else { + d << '0'; + } + d << ')'; return d; } @@ -297,7 +300,7 @@ QMimeData *QWindowsClipboard::mimeData(QClipboard::Mode mode) void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) { - qCDebug(lcQpaMime) << __FUNCTION__ << mode << *mimeData; + qCDebug(lcQpaMime) << __FUNCTION__ << mode << mimeData; if (mode != QClipboard::Clipboard) return; diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.h b/src/plugins/platforms/windows/qwindowsinternalmimedata.h index 09ab417268..6a60a9676a 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.h +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.h @@ -55,8 +55,6 @@ protected: virtual void releaseDataObject(IDataObject *) const {} }; -QDebug operator<<(QDebug d, const QMimeData &m); - QT_END_NAMESPACE #endif // QWINDOWSINTERNALMIME_H -- cgit v1.2.3