On Fri, May 15, 2015 at 12:04:50PM +0200, Stephan Witt wrote:
> 
> I'll try to get it running on Linux to see how it works there. Meanwhile,
> I'm interested in comments.

Please, don't pass back and forth QPixmap objects on the stack. These
are big objects, potentially. Instead, use

bool getPixmap(QString const & path, QPixmap & pm)
{
        // deal with QPixmap

        return !pm.isNull();
}

> 
> diff --git a/src/frontends/qt4/GuiApplication.cpp 
> b/src/frontends/qt4/GuiApplication.cpp
> index eaf33c4..de4569a 100644
> --- a/src/frontends/qt4/GuiApplication.cpp
> +++ b/src/frontends/qt4/GuiApplication.cpp
> @@ -569,22 +569,39 @@ QString iconName(FuncRequest const & f, bool unknown)
>       return QString();
>  }
>  
> -QPixmap getPixmap(QString const & path, QString const & name, QString const 
> & ext)
> +QPixmap getPixmap(QString const & path)
>  {
>       QPixmap pixmap;
> +     if (pixmap.load(path)) {
> +             if (path.endsWith(".svgz") || path.endsWith(".svg") ) {
> +                     GuiApplication const * guiApp = theGuiApp();
> +                     if (guiApp != 0) {
> +                             
> pixmap.setDevicePixelRatio(guiApp->pixelRatio());
> +                     }
> +             }
> +             return pixmap;
> +     }
> +     return QPixmap();
> +}
> +
> +QPixmap getPixmap(QString const & path, QString const & name, QString const 
> & ext)
> +{
>       QString imagedir = path;
>       FileName fname = imageLibFileSearch(imagedir, name, ext, 
> theGuiApp()->imageSearchMode());
>       QString fpath = toqstr(fname.absFileName());
> +     QPixmap pixmap = getPixmap(fpath);
>  
> -     if (pixmap.load(fpath)) {
> +     if (!pixmap.isNull()) {
>               return pixmap;
> -     } else {
> -         QStringList exts = ext.split(",");
> -         fpath = ":/" + path + name + ".";
> -         for (int i = 0; i < exts.size(); ++i) {
> -             if (pixmap.load(fpath + exts.at(i)))
> +     }
> +     
> +     QStringList exts = ext.split(",");
> +     fpath = ":/" + path + name + ".";
> +     for (int i = 0; i < exts.size(); ++i) {
> +             pixmap = getPixmap(fpath + exts.at(i));
> +             if (!pixmap.isNull()) {
>                       return pixmap;
> -         }
> +             }
>       }
>  
>       bool const list = ext.contains(",");
> @@ -613,13 +630,13 @@ QIcon getIcon(FuncRequest const & f, bool unknown)
>               return QIcon();
>  
>       //LYXERR(Debug::GUI, "Found icon: " << icon);
> -     QPixmap pm;
> -     if (!pm.load(icon)) {
> +     QPixmap pixmap = getPixmap(icon);
> +     if (pixmap.isNull()) {
>               LYXERR0("Cannot load icon " << icon << " please verify resource 
> system!");
>               return QIcon();
>       }
>  
> -     return QIcon(pm);
> +     return QIcon(pixmap);
>  }
>  
>  

-- 
Enrico

Reply via email to