]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsCacheItem.C
Quote graphics conversion commands correctly.
[lyx.git] / src / graphics / GraphicsCacheItem.C
index 59973327d441815b6bbf1ff202eb94fc5f7c8e6c..0133bd6a06ffa73d532d1eb747cf86fa226ee440 100644 (file)
@@ -17,6 +17,7 @@
 #include "GraphicsImage.h"
 
 #include "debug.h"
+#include "format.h"
 
 #include "support/filetools.h"
 #include "support/FileMonitor.h"
@@ -32,7 +33,6 @@ using support::FileMonitor;
 using support::IsFileReadable;
 using support::MakeDisplayPath;
 using support::OnlyFilename;
-using support::getExtFromContents;
 using support::tempName;
 using support::unlink;
 using support::unzipFile;
@@ -46,7 +46,8 @@ using std::string;
 namespace lyx {
 namespace graphics {
 
-struct CacheItem::Impl : public boost::signals::trackable {
+class CacheItem::Impl : public boost::signals::trackable {
+public:
 
        ///
        Impl(string const & file);
@@ -122,7 +123,7 @@ struct CacheItem::Impl : public boost::signals::trackable {
        ImageStatus status_;
 
        /// This signal is emitted when the image loading status changes.
-       boost::signal0<void> statusChanged;
+       boost::signal<void()> statusChanged;
 
        /// The connection to the signal Image::finishedLoading
        boost::signals::connection cl_;
@@ -401,7 +402,13 @@ void CacheItem::Impl::convertToDisplayFormat()
                << "\n\twith displayed filename: " << displayed_filename
                << endl;
 
-       string from = getExtFromContents(filename);
+       string const from = formats.getFormatFromFile(filename);
+       if (from.empty()) {
+               setStatus(ErrorConverting);
+               lyxerr[Debug::GRAPHICS]
+                       << "\tCould not determine file format." << endl;
+               return;
+       }
        lyxerr[Debug::GRAPHICS]
                << "\n\tThe file contains " << from << " format data." << endl;
        string const to = findTargetFormat(from);