Cocoa: fix crash regression in qt_mac_create_nsimage()
The regression was introduced in d8857f21ac264. The original change was meant to fix support for SVG icons, but failed to take into account a valid QIcon with no sizes, but which is also unable to create a pixmap for the requested size. Task-number: QTBUG-58344 Change-Id: I7ac1dbfaf6e3dab8581fe4b33c814e2517fcdba8 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
cbd7dea83e
commit
59780d132a
@ -157,6 +157,8 @@ NSImage *qt_mac_create_nsimage(const QIcon &icon, int defaultSize)
|
||||
availableSizes << QSize(defaultSize, defaultSize);
|
||||
foreach (QSize size, availableSizes) {
|
||||
QPixmap pm = icon.pixmap(size);
|
||||
if (pm.isNull())
|
||||
continue;
|
||||
QImage image = pm.toImage();
|
||||
CGImageRef cgImage = qt_mac_toCGImage(image);
|
||||
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
|
||||
|
@ -136,6 +136,7 @@ private slots:
|
||||
void QTBUG_57404_existingMenuItemException();
|
||||
#endif
|
||||
void taskQTBUG55966_subMenuRemoved();
|
||||
void QTBUG_58344_invalidIcon();
|
||||
|
||||
void platformMenu();
|
||||
|
||||
@ -1594,5 +1595,14 @@ void tst_QMenuBar::taskQTBUG55966_subMenuRemoved()
|
||||
QTest::qWait(500);
|
||||
}
|
||||
|
||||
void tst_QMenuBar::QTBUG_58344_invalidIcon()
|
||||
{
|
||||
QMenuBar menuBar;
|
||||
QMenu menu("menu");
|
||||
menu.addAction(QIcon("crash.png"), "crash");
|
||||
menuBar.addMenu(&menu);
|
||||
// No crash, all fine.
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMenuBar)
|
||||
#include "tst_qmenubar.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user