forked from qt-creator/qt-creator
QmlDesigner: Check if callback is not null
The AsynchronousImageFactory is not interested in any callback. So it is providing null callbacks. If they are called there will be a crash. Change-Id: I252301e4289185e50720849a7cb148d8f1da3e7d Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -485,4 +485,40 @@ TEST_F(ImageCacheGenerator, MergeAbortCallbackIfTasksAreMerged)
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, DontCallNullImageCallback)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(_, _, _, _, _))
|
||||
.WillOnce([&](auto, auto, auto, auto captureCallback, auto) {
|
||||
captureCallback(image1, smallImage1);
|
||||
notification.notify();
|
||||
});
|
||||
|
||||
generator.generateImage("name", {}, {}, {}, {}, {});
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, DontCallNullAbortCallbackForNullImage)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(_, _, _, _, _))
|
||||
.WillOnce([&](auto, auto, auto, auto captureCallback, auto) {
|
||||
captureCallback(QImage{}, QImage{});
|
||||
notification.notify();
|
||||
});
|
||||
|
||||
generator.generateImage("name", {}, {}, {}, {}, {});
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, DontCallNullAbortCallback)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(_, _, _, _, _))
|
||||
.WillOnce([&](auto, auto, auto, auto, auto abortCallback) {
|
||||
abortCallback(QmlDesigner::ImageCache::AbortReason::Failed);
|
||||
notification.notify();
|
||||
});
|
||||
|
||||
generator.generateImage("name", {}, {}, {}, {}, {});
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user