diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 1065822cc..44f9656fb 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -194,6 +194,9 @@ bool BitmapFactoryInst::loadPixmap(const QString& filename, QPixmap& icon) const { QFileInfo fi(filename); if (fi.exists()) { + // There is a crash when using the Webkit engine in debug mode + // for a couple of SVG files. Thus, use the qsvg plugin. +#if QT_VERSION < 0x040800 || !defined(_DEBUG) // first check if it's an SVG because Qt's qsvg4 module shouldn't be used therefore if (fi.suffix().toLower() == QLatin1String("svg")) { QFile svgFile(filename); @@ -206,6 +209,9 @@ bool BitmapFactoryInst::loadPixmap(const QString& filename, QPixmap& icon) const // try with Qt plugins icon.load(filename); } +#else + icon.load(filename); +#endif } return !icon.isNull(); @@ -314,15 +320,20 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize webView.setPalette(pal); webView.setContent(contents, QString::fromAscii("image/svg+xml")); QString node = QString::fromAscii("document.rootElement.nodeName"); - QString root = webView.page()->mainFrame()->evaluateJavaScript(node).toString(); + QWebFrame* frame = webView.page()->mainFrame(); + if (!frame) { + return QPixmap(); + } + + QString root = frame->evaluateJavaScript(node).toString(); if (root.isEmpty() || root.compare(QLatin1String("svg"), Qt::CaseInsensitive)) { return QPixmap(); } QString w = QString::fromAscii("document.rootElement.width.baseVal.value"); QString h = QString::fromAscii("document.rootElement.height.baseVal.value"); - double ww = webView.page()->mainFrame()->evaluateJavaScript(w).toDouble(); - double hh = webView.page()->mainFrame()->evaluateJavaScript(h).toDouble(); + double ww = frame->evaluateJavaScript(w).toDouble(); + double hh = frame->evaluateJavaScript(h).toDouble(); if (ww == 0.0 || hh == 0.0) return QPixmap(); #endif @@ -341,7 +352,7 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize p.setRenderHint(QPainter::TextAntialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setOpacity(0); // important to keep transparent background - webView.page()->mainFrame()->render(&p); + frame->render(&p); #else // tmp. disable the report window to suppress some bothering warnings Base::Console().SetEnabledMsgType("ReportOutput", ConsoleMsgType::MsgType_Wrn, false);