]> git.lyx.org Git - lyx.git/blobdiff - src/Format.cpp
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / Format.cpp
index ff03ab52ff4cc17b6a56a4136344f27ab46f3b91..c9e1381992ffd80cb232ad7b179d5bea7910a232 100644 (file)
@@ -402,11 +402,19 @@ string Formats::getFormatFromFile(FileName const & filename) const
                                        << "\tCouldn't load magic database - "
                                        << magic_error(magic_cookie));
                        } else {
-                               string mime = magic_file(magic_cookie,
+                               char const * result = magic_file(magic_cookie,
                                        filename.toFilesystemEncoding().c_str());
-                               mime = token(mime, ';', 0);
+                               string mime;
+                               if (result)
+                                       mime = token(result, ';', 0);
+                               else {
+                                       LYXERR(Debug::GRAPHICS, "Formats::getFormatFromFile\n"
+                                               << "\tCouldn't query magic database - "
+                                               << magic_error(magic_cookie));
+                               }
                                // we need our own ps/eps detection
-                               if ((mime != "application/postscript") && (mime != "text/plain")) {
+                               if (!mime.empty() && mime != "application/postscript" &&
+                                   mime != "text/plain") {
                                        Formats::const_iterator cit =
                                                find_if(formatlist.begin(), formatlist.end(),
                                                        FormatMimeEqual(mime));
@@ -469,6 +477,7 @@ struct ZippedInfo {
 };
 
 
+// FIXME THREAD
 /// Mapping absolute pathnames of files to their ZippedInfo metadata.
 static std::map<std::string, ZippedInfo> zipped_;
 
@@ -788,7 +797,7 @@ FlavorTranslator initFlavorTranslator()
 
 FlavorTranslator const & flavorTranslator()
 {
-       static FlavorTranslator translator = initFlavorTranslator();
+       static FlavorTranslator const translator = initFlavorTranslator();
        return translator;
 }