mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-15 20:37:08 +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;
|
||||
timer.start();
|
||||
QSharedPointer<QQuickItemGrabResult> result = item->grabToImage();
|
||||
pendingGrabbersLocker.lockForWrite();
|
||||
pendingGrabbers << result.data();
|
||||
pendingGrabbersLocker.unlock();
|
||||
|
||||
connect(result.data(), &QQuickItemGrabResult::ready, this, &ImageHandler::imageGrabberReady);
|
||||
while (timer.elapsed() < 1000) {
|
||||
pendingGrabbersLocker.lockForRead();
|
||||
if (!pendingGrabbers.contains(result.data())) {
|
||||
pendingGrabbersLocker.unlock();
|
||||
break;
|
||||
}
|
||||
if (result) {
|
||||
pendingGrabbersLocker.lockForWrite();
|
||||
pendingGrabbers << result.data();
|
||||
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
|
||||
QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user