I noticed something interesting today. I had a Windows laptop where I used the Qt5.5 libraries and git master lyx sources. It compiled fine and the toolbar icons were all fine. Today, I compiled it on a fresh Win8 desktop using Qt5.6 and Lyx git master and all icons disappeared!
 
But this is most likely a false diagnostic. In my previous laptop, I had the stable bundle installed, so most likely it was sourcing icons from that. In a fresh install, ann icons disappear because I noticed all icons are .svgz now. So I patched GuiApplication.cpp to use QtSVGRenderer to paint the svg onto a QPixMap - as far as the rest of the code is concerned, its still getting a PixMap and not a SVG for rendering directly on the canvas. Now how are other follks getting to see the images in Qt5.6 without this change? I'm confused!
 
-Shankar
 
PS:- Attaching patch used in plaintext inline as well as attachment.
 
diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp
index 12f99d5..9edf05f 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -101,6 +101,7 @@
 #include <QMenuBar>
 #include <QMimeData>
 #include <QObject>
+#include <QPainter>
 #include <QPixmap>
 #include <QPixmapCache>
 #include <QRegExp>
@@ -110,6 +111,7 @@
 #include <QSocketNotifier>
 #include <QSortFilterProxyModel>
 #include <QStandardItemModel>
+#include <QSvgRenderer>
 #include <QTextCodec>
 #include <QTimer>
 #include <QTranslator>
@@ -552,18 +554,27 @@ QString iconName(FuncRequest const & f, bool unknown)
 
 bool getPixmap(QPixmap & pixmap, QString const & path)
 {
-    if (pixmap.load(path)) {
+    bool success;
 #if QT_VERSION >= 0x050000
-        if (path.endsWith(".svgz") || path.endsWith(".svg") ) {
-            GuiApplication const * guiApp = theGuiApp();
-            if (guiApp != 0) {
-                pixmap.setDevicePixelRatio(guiApp->pixelRatio());
-            }
+    if (path.endsWith(".svgz") || path.endsWith(".svg") ) {
+        GuiApplication const * guiApp = theGuiApp();
+        if (guiApp != 0) {
+            pixmap.setDevicePixelRatio(guiApp->pixelRatio());
         }
-#endif
-        return true;
+        QSvgRenderer renderer;
+        success = renderer.load(path);
+        pixmap = QPixmap(16, 16);  //UGLY: Does not work without this. Why???
+        QPainter painter(&pixmap);
+        renderer.render(&painter);
     }
-    return false;
+    else {
+        success = pixmap.load(path);
+    }
+        
+#else
+    success = pixmap.load(path);
+#endif
+    return success;
 }
 

Attachment: svg_icon_fix.patch
Description: Binary data

Reply via email to