]> sigrok.org Git - pulseview.git/commitdiff
Fix SVG icons not being displayed on Windows.
authorUwe Hermann <redacted>
Wed, 8 Jan 2014 23:49:47 +0000 (00:49 +0100)
committerUwe Hermann <redacted>
Thu, 9 Jan 2014 00:07:32 +0000 (01:07 +0100)
On Windows (where we use a static Qt) we need to include plugins
(in this case "qsvg" a.k.a. libqsvg.a from plugins/imageformats/),
otherwise SVGs (such as various icons in PulseView) cannot be displayed.
For this we need to use Q_IMPORT_PLUGIN(qsvg) in the code, pass the
QT_STATICPLUGIN flag to the compiler, and link against "-lqsvg".

This, in turn, requires that we also link against the similarly named QtSvg
component/lib (${QT_QTSVG_LIBRARY} a.k.a libQtSvg.a).

See also: https://qt-project.org/doc/qt-4.8/plugins-howto.html#static-plugins

This fixes bug #239.

CMakeLists.txt
main.cpp

index 8302b4828cc3fff1cfaca42926ba0481c0c50996..3859c9133b61e01ffb93599f684fd550470e6a48 100644 (file)
@@ -278,6 +278,15 @@ else()
        list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES})
 endif()
 
+if(WIN32)
+       # On Windows we need to statically link the libqsvg imageformat
+       # plugin (and the QtSvg component) for SVG graphics/icons to work.
+       add_definitions(-DQT_STATICPLUGIN)
+       link_directories("${QT_PLUGINS_DIR}/imageformats")
+       list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY})
+       list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg")
+endif()
+
 add_executable(${PROJECT_NAME}
        ${pulseview_SOURCES}
        ${pulseview_HEADERS_MOC}
index 3fa93c4586951c81618141a2ab5f7d28a6af3646..2c6a59efd22c8d14d181223c45c1abc92279e9d4 100644 (file)
--- a/main.cpp
+++ b/main.cpp
 
 #include "config.h"
 
+#ifdef _WIN32
+// The static qsvg lib is required for SVG graphics/icons (on Windows).
+#include <QtPlugin>
+Q_IMPORT_PLUGIN(qsvg)
+#endif
+
 void usage()
 {
        fprintf(stdout,