]> git.lyx.org Git - features.git/commitdiff
Make sure an unzipped file has correct extension.
authorEnrico Forestieri <forenr@lyx.org>
Fri, 13 Mar 2015 16:24:09 +0000 (17:24 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 13 Mar 2015 16:28:18 +0000 (17:28 +0100)
If a mask is missing, the TempFile class appends it to the filename.
This may be a problem with applications relying on the extension,
so explicitly add a mask.

src/graphics/GraphicsCacheItem.cpp

index 4d18ce0778e7d5c86fce8bee59631f3aa64908aa..9fab10dbf9c4549363efcf780c10a87234b61f82 100644 (file)
@@ -362,7 +362,11 @@ bool CacheItem::Impl::tryDisplayFormat(FileName & filename, string & from)
 
        zipped_ = formats.isZippedFile(filename_);
        if (zipped_) {
-               TempFile tempfile(filename_.toFilesystemEncoding());
+               string tempname = unzippedFileName(filename_.toFilesystemEncoding());
+               string const ext = getExtension(tempname);
+               if (!ext.empty())
+                       tempname = changeExtension(tempname, "");
+               TempFile tempfile(tempname + "-XXXXXX." + ext);
                tempfile.setAutoRemove(false);
                unzipped_filename_ = tempfile.name();
                if (unzipped_filename_.empty()) {