]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiImage.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiImage.cpp
index c4571c7d4b797c1ecc07af838b2c938fd1a256e2..e7defe7ec585933bd5d3cb5dcd6e5230c5ecb97d 100644 (file)
@@ -165,24 +165,20 @@ bool GuiImage::scale(Params const & params)
 {
        QImage const & image = is_transformed_ ? transformed_ : original_;
 
-       unsigned int w = image.width();
-       unsigned int h = image.height();
+       if (params.scale == 100)
+               return false;
 
-       // scale only when value > 0
-       if (params.scale > 0) {
-               w = (w * params.scale) / 100;
-               h = (h * params.scale) / 100;
-       }
+       qreal scale = qreal(params.scale) / 100.0;
 
-       LYXERR(Debug::GRAPHICS, "\n\tparams.scale  : " << params.scale
-                                << "\n\twidth         : " << w
-                                << "\n\theight        : " << h);
+#if (QT_VERSION >= 0x040500) && (QT_VERSION <= 0x040502)
+       // Due to a bug in Qt, LyX will crash for certain
+       // scaling factors and sizes of the image.
+       // see bug #5957: http://www.lyx.org/trac/ticket/5957
+       scale += 0.0001;
+#endif
 
-       if (w == image.width() && h == image.height())
-               return false;
-       
        QMatrix m;
-       m.scale(double(w) / image.width(), double(h) / image.height());
+       m.scale(scale, scale);
        transformed_ = image.transformed(m);
        return true;
 }