diff options
author | hjk <[email protected]> | 2019-10-01 16:36:42 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2019-10-01 14:57:14 +0000 |
commit | 312ff692b02d6b19f39303591c7dc0156bf46661 (patch) | |
tree | 299a724c2fb9c845b4408b8b25755af9a74e2f0f /src/plugins/debugger/watchhandler.cpp | |
parent | 0907bc8658fdb82efdaa07013ae164642856938a (diff) |
Debugger: Do not crash when displaying uninitialized QImages
Fixes: QTCREATORBUG-23031
Change-Id: I074cdaf509edac6e5659d2e976ed7188e8944d81
Reviewed-by: Mitch Curtis <[email protected]>
Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/plugins/debugger/watchhandler.cpp')
-rw-r--r-- | src/plugins/debugger/watchhandler.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 9eccfbdb1eb..66d73e84bf9 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -2296,15 +2296,20 @@ void WatchModel::showEditValue(const WatchItem *item) QTC_ASSERT(0 < nbytes && nbytes < 10000 * 10000, return); QTC_ASSERT(0 < imformat && imformat < 32, return); QImage im(width, height, QImage::Format(imformat)); - std::memcpy(im.bits(), bits, nbytes); - auto v = m_separatedView->prepareObject<ImageViewer>(item); - v->setInfo(item->address ? - tr("%1 Object at %2").arg(item->type, item->hexAddress()) : - tr("%1 Object at Unknown Address").arg(item->type) + " " + - ImageViewer::tr("Size: %1x%2, %3 byte, format: %4, depth: %5") - .arg(width).arg(height).arg(nbytes).arg(im.format()).arg(im.depth()) - ); - v->setImage(im); + const qsizetype size = im.sizeInBytes(); + // If our computation of image size doesn't fit the client's + // chances are that we can't properly display it either. + if (size == nbytes) { + std::memcpy(im.bits(), bits, nbytes); + auto v = m_separatedView->prepareObject<ImageViewer>(item); + v->setInfo(item->address ? + tr("%1 Object at %2").arg(item->type, item->hexAddress()) : + tr("%1 Object at Unknown Address").arg(item->type) + " " + + ImageViewer::tr("Size: %1x%2, %3 byte, format: %4, depth: %5") + .arg(width).arg(height).arg(nbytes).arg(im.format()).arg(im.depth()) + ); + v->setImage(im); + } } else if (format == DisplayLatin1String || format == DisplayUtf8String || format == DisplayUtf16String |