mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-19 06:16:51 +00:00
Fixed crash when loading invalid image. (#160)
* Fixed crash when loading invalid image. * Fixed crash when loading invalid image (part2).
This commit is contained in:
parent
29597353ec
commit
dac9480a65
@ -36,22 +36,24 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY,
|
|||||||
QTime timer;
|
QTime timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
QSharedPointer<QQuickItemGrabResult> result = item->grabToImage();
|
QSharedPointer<QQuickItemGrabResult> result = item->grabToImage();
|
||||||
pendingGrabbersLocker.lockForWrite();
|
if (result) {
|
||||||
pendingGrabbers << result.data();
|
pendingGrabbersLocker.lockForWrite();
|
||||||
pendingGrabbersLocker.unlock();
|
pendingGrabbers << result.data();
|
||||||
|
|
||||||
connect(result.data(), &QQuickItemGrabResult::ready, this, &ImageHandler::imageGrabberReady);
|
|
||||||
while (timer.elapsed() < 1000) {
|
|
||||||
pendingGrabbersLocker.lockForRead();
|
|
||||||
if (!pendingGrabbers.contains(result.data())) {
|
|
||||||
pendingGrabbersLocker.unlock();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pendingGrabbersLocker.unlock();
|
pendingGrabbersLocker.unlock();
|
||||||
qApp->processEvents();
|
|
||||||
QThread::yieldCurrentThread();
|
connect(result.data(), &QQuickItemGrabResult::ready, this, &ImageHandler::imageGrabberReady);
|
||||||
|
while (timer.elapsed() < 1000) {
|
||||||
|
pendingGrabbersLocker.lockForRead();
|
||||||
|
if (!pendingGrabbers.contains(result.data())) {
|
||||||
|
pendingGrabbersLocker.unlock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pendingGrabbersLocker.unlock();
|
||||||
|
qApp->processEvents();
|
||||||
|
QThread::yieldCurrentThread();
|
||||||
|
}
|
||||||
|
img = result->image();
|
||||||
}
|
}
|
||||||
img = result->image();
|
|
||||||
#else // QT_VERSION >= 0x050000
|
#else // QT_VERSION >= 0x050000
|
||||||
QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);
|
QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user