chore: temporary limit svg support to Tiny 1.2-only

This commit is contained in:
Gary Wang 2024-06-28 18:40:50 +08:00
parent f8587020d7
commit c636b14af8
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760

View File

@ -10,6 +10,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QUrl> #include <QUrl>
#include <QGraphicsSvgItem> #include <QGraphicsSvgItem>
#include <QSvgRenderer>
#include <QMovie> #include <QMovie>
#include <QPainter> #include <QPainter>
@ -116,7 +117,16 @@ void GraphicsScene::showText(const QString &text)
void GraphicsScene::showSvg(const QString &filepath) void GraphicsScene::showSvg(const QString &filepath)
{ {
this->clear(); this->clear();
QGraphicsSvgItem * svgItem = new QGraphicsSvgItem(filepath); QGraphicsSvgItem * svgItem = new QGraphicsSvgItem();
QSvgRenderer * render = new QSvgRenderer(svgItem);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
// Qt 6.7.0's SVG support is terrible caused by huge memory usage, see QTBUG-124287
// Qt 6.7.1's is somewhat better, memory issue seems fixed, but still laggy when zoom in
// Anyway let's disable it for now.
render->setOptions(QtSvg::Tiny12FeaturesOnly);
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
render->load(filepath);
svgItem->setSharedRenderer(render);
this->addItem(svgItem); this->addItem(svgItem);
m_theThing = svgItem; m_theThing = svgItem;
this->setSceneRect(m_theThing->boundingRect()); this->setSceneRect(m_theThing->boundingRect());