diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-03-31 12:11:30 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-03-31 12:11:30 +0000 |
| commit | 00ea3a2ecf217ccd1889b6036054018b6b69105e (patch) | |
| tree | d611ddc875f766f4e32af29f5ac764037dcd0983 /src/ui/widget/imageicon.cpp | |
| parent | Fixed bug in LPE Bspline widget, on apply selected nodes, because a rounding ... (diff) | |
| parent | Fix Gtkmm 3.8 build issues on systems with Gtk+ 3.10 (diff) | |
| download | inkscape-00ea3a2ecf217ccd1889b6036054018b6b69105e.tar.gz inkscape-00ea3a2ecf217ccd1889b6036054018b6b69105e.zip | |
update to trunk
(bzr r11950.1.319)
Diffstat (limited to 'src/ui/widget/imageicon.cpp')
| -rw-r--r-- | src/ui/widget/imageicon.cpp | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index cf41a16a4..22abd04ba 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -369,60 +369,47 @@ isValidImageIconFile(const Glib::ustring &fileName) return false; } +/// \fixme This function is almost an exact duplicate of SVGPreview::set() in ui/dialog/filedialogimpl-gtkmm.cpp. bool ImageIcon::show(const Glib::ustring &fileName) { - - if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) + if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) { + showBrokenImage("File does not exist"); return false; + } - gchar *fName = const_cast<gchar *>(fileName.c_str()); - //g_message("fname:%s\n", fName); - - - if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) - { + if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) { + gchar *fName = const_cast<gchar *>(fileName.c_str()); // this const-cast seems not necessary, was it put there because of older sys/stat.h version? struct stat info; - if (g_file_test (fName, G_FILE_TEST_EXISTS) && stat(fName, &info)) - { - Glib::ustring err = "cannot get file info"; - showBrokenImage(err); + if (stat(fName, &info)) // stat returns 0 upon success + { + showBrokenImage("Cannot get file info"); return false; - } - long fileLen = info.st_size; - if (fileLen > 0x150000L) - { - Glib::ustring err = "File too large"; - showBrokenImage(err); + } + if (info.st_size > 0x150000L) { + showBrokenImage("File too large"); return false; - } } + } Glib::ustring svg = ".svg"; Glib::ustring svgz = ".svgz"; - if (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz) ) - { - if (!showSvgFile(fileName)) - { + if (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz)) { + if (!showSvgFile(fileName)) { showBrokenImage(bitmapError); return false; - } - return true; } - else if (isValidImageIconFile(fileName)) - { - if (!showBitmap(fileName)) - { + return true; + } else if (isValidImageIconFile(fileName)) { + if (!showBitmap(fileName)) { showBrokenImage(bitmapError); return false; - } - return true; } - else - { + return true; + } else { showBrokenImage("unsupported file type"); return false; - } + } } |
