X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiImage.cpp;h=e7defe7ec585933bd5d3cb5dcd6e5230c5ecb97d;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=bc869d2cdbe3af612f7dc2933dacfc4353566ad9;hpb=482468dda605bd4e159a4e1c60930790087b3582;p=lyx.git diff --git a/src/frontends/qt4/GuiImage.cpp b/src/frontends/qt4/GuiImage.cpp index bc869d2cdb..e7defe7ec5 100644 --- a/src/frontends/qt4/GuiImage.cpp +++ b/src/frontends/qt4/GuiImage.cpp @@ -31,8 +31,8 @@ using namespace lyx::support; namespace lyx { namespace graphics { -/// Access to this class is through this static method. -Image * GuiImage::newImage() +/// Implement factory method defined in GraphicsImage.h +Image * newImage() { return new GuiImage; } @@ -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; }