]> git.lyx.org Git - features.git/commitdiff
Do not duplicate jpg format
authorGeorg Baum <baum@lyx.org>
Thu, 2 Jun 2016 20:31:27 +0000 (22:31 +0200)
committerGeorg Baum <baum@lyx.org>
Thu, 2 Jun 2016 20:31:27 +0000 (22:31 +0200)
Some qt versions report both "jpeg" and "jpg" as loadable file extensions.
In this case the jpg format was added twice previously. This does not happen
anymore with the new code, and it works as well if only "jpg" or only "jpeg"
is reported.

src/frontends/qt4/GuiApplication.cpp

index b3efd78a09bf1808711f92943ae67e46b6a8b4ca..1513636867f85e794d5e0557eb657256946cae11 100644 (file)
@@ -227,14 +227,25 @@ vector<string> loadableImageFormats()
        if (qt_formats.empty())
                LYXERR(Debug::GRAPHICS, "\nQt4 Problem: No Format available!");
 
+       bool jpeg_found = false;
+       bool jpg_found = false;
        for (QList<QByteArray>::const_iterator it = qt_formats.begin(); it != qt_formats.end(); ++it) {
 
                LYXERR(Debug::GRAPHICS, (const char *) *it << ", ");
 
                string ext = ascii_lowercase((const char *) *it);
                // special case
-               if (ext == "jpeg")
+               if (ext == "jpeg") {
+                       jpeg_found = true;
+                       if (jpg_found)
+                               continue;
                        ext = "jpg";
+               }
+               else if (ext == "jpg") {
+                       jpg_found = true;
+                       if (jpeg_found)
+                               continue;
+               }
                fmts.push_back(ext);
        }