]> git.lyx.org Git - lyx.git/blobdiff - src/Format.cpp
Revert "Fix bug with wrong baseline calculation in last paragraph"
[lyx.git] / src / Format.cpp
index ff7fb3461366aee11199f6991093eb198435ee55..1637bed5b43e2ceb7a2e19d9f4cbcfbe307ea4b6 100644 (file)
@@ -22,6 +22,7 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
+#include "support/mutex.h"
 #include "support/os.h"
 #include "support/PathChanger.h"
 #include "support/Systemcall.h"
@@ -32,7 +33,7 @@
 #include <map>
 #include <ctime>
 
-// FIXME: Q_WS_MACX is not available, it's in Qt
+// FIXME: Q_OS_MAC is not available, it's in Qt
 #ifdef USE_MACOSX_PACKAGING
 #include "support/linkback/LinkBackProxy.h"
 #endif
@@ -241,17 +242,13 @@ string guessFormatFromContents(FileName const & fn)
        int const max_count = 50;
        int count = 0;
 
-       // Maximum number of binary chars allowed for latex detection
-       int const max_bin = 5;
-
        string str;
        string format;
        bool firstLine = true;
        bool backslash = false;
        bool maybelatex = false;
-       int binchars = 0;
        int dollars = 0;
-       while ((count++ < max_count) && format.empty() && binchars <= max_bin) {
+       while ((count++ < max_count) && format.empty() && !maybelatex) {
                if (ifs.eof())
                        break;
 
@@ -378,11 +375,9 @@ string guessFormatFromContents(FileName const & fn)
                                // inline equation
                                maybelatex = true;
                }
-
-               binchars += count_bin_chars(str);
        }
 
-       if (format.empty() && binchars <= max_bin && maybelatex)
+       if (format.empty() && maybelatex && !isBinaryFile(fn))
                format = "latex";
 
        if (format.empty()) {
@@ -509,14 +504,15 @@ struct ZippedInfo {
 };
 
 
-// FIXME THREAD
 /// Mapping absolute pathnames of files to their ZippedInfo metadata.
 static std::map<std::string, ZippedInfo> zipped_;
+static Mutex zipped_mutex;
 
 
 bool Formats::isZippedFile(support::FileName const & filename) const {
        string const & fname = filename.absFileName();
        time_t timestamp = filename.lastModified();
+       Mutex::Locker lock(&zipped_mutex);
        map<string, ZippedInfo>::iterator it = zipped_.find(fname);
        if (it != zipped_.end() && it->second.timestamp == timestamp)
                return it->second.zipped;