]> git.lyx.org Git - lyx.git/commitdiff
No need to compute size of an icon if not using GUI.
authorKornel Benko <kornel@lyx.org>
Sat, 28 Mar 2015 20:05:41 +0000 (21:05 +0100)
committerKornel Benko <kornel@lyx.org>
Sat, 28 Mar 2015 20:05:41 +0000 (21:05 +0100)
This also avoids crash while calling Qimage() without GUI.

src/insets/InsetInfo.cpp

index acf073aa107103064ee5fd4e67d8a4e1fb1e1359..ac2fd03143be197d6fcc7e0d140283b439b050d3 100644 (file)
@@ -10,7 +10,7 @@
 #include <config.h>
 
 #include "InsetInfo.h"
-
+#include "LyX.h"
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
@@ -419,10 +419,12 @@ void InsetInfo::updateInfo()
                if (!file.exists())
                        break;
                int percent_scale = 100;
-               int imgsize = QImage(toqstr(file.absFileName())).width();
-               if (imgsize > 0) {
-                       int iconsize = Length(1, Length::EM).inPixels(1);
-                       percent_scale = (100 * iconsize + imgsize / 2)/imgsize;
+               if (use_gui) {
+                       int imgsize = QImage(toqstr(file.absFileName())).width();
+                       if (imgsize > 0) {
+                               int iconsize = Length(1, Length::EM).inPixels(1);
+                               percent_scale = (100 * iconsize + imgsize / 2)/imgsize;
+                       }
                }
                InsetGraphics * inset = new InsetGraphics(buffer_);
                InsetGraphicsParams igp;