Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.1
-
None
Description
QSvgGenerator does not render QSvgIconEngine based icons if they are drawn using QIcon::paint method. This seems to be a regression from Qt 5.8.1
Example (from the attached project):
QIcon icon_svg(":/test/input.svg"); assert(!icon_svg.isNull()); QPixmap icn_pix(icon_svg.pixmap(32)); assert(!icn_pix.isNull()); QSvgGenerator gen; gen.setViewBox(QRect(0, 0, 256, 256)); QBuffer contents; gen.setOutputDevice(&contents); QPainter p(&gen); icon_svg.paint(&p, QRect(0, 0, 32, 32)); // This does not work ... p.drawPixmap(QRect(64, 0, 32, 32), icn_pix); // ... but this does qDebug() << "devicePixelRatioF: " << p.device()->devicePixelRatioF() << "\n"; p.end(); qDebug() << QString::fromUtf8(contents.buffer());
Note that QSvgGenerator has a very peculiar devicePixelRatioF of 1.52588e-05.
This is probably the cause of this behavior because this value is multiplied into requested size by QSvgIconEngine::paint