← All bug reports

FS#907I, M file dialog doesn't work as intended (with fix)

Type
Bug
Status
Closed
Resolution
Fixed
Category
QCAD (main)
Severity
Low
Priority
Low
Reported version
3.2.2
Operating system
All
Reported
2013-09-05 by kazmer
Closed
2013-09-05 by andrew

In scripts/Draw/Image/Image.js, while building the filter for the file dialog, constructs like this are used:

var formats = QImageReader.supportedImageFormats();

for (var i=0; i<formats.length; ++i) {
    var format = formats[i];

        if (format==="jpg" ||
            format==="tif") {
            continue;
        }

=== also checks for type equality, and since format is actually an object, it will never match. The result is that duplicates are not filtered from the list as the code suggests they were intended to be filtered, nor are formats that are not intended to be there.

The following patch fixes this:

diff --git a/scripts/Draw/Image/Image.js b/scripts/Draw/Image/Image.js
index 0a6400e..cc58c98 100644
--- a/scripts/Draw/Image/Image.js
+++ b/scripts/Draw/Image/Image.js
@@ -91,23 +91,23 @@ Image.prototype.getFileName = function() {
         var formatAlt = "";
 
         // ignore format aliases:
-        if (format==="jpg" ||
-            format==="tif") {
+        if (format=="jpg" ||
+            format=="tif") {
             continue;
         }
 
         // ignore unsupported formats:
-        if (format==="ico" || format==="mng" ||
-            format==="pbm" || format==="pgm" || format==="ppm" ||
-            format==="svg" || format==="svgz" ||
-            format==="xbm" || format==="xpm") {
+        if (format=="ico" || format=="mng" ||
+            format=="pbm" || format=="pgm" || format=="ppm" ||
+            format=="svg" || format=="svgz" ||
+            format=="xbm" || format=="xpm") {
             continue;
         }
 
-        if (format==="jpeg") {
+        if (format=="jpeg") {
             formatAlt = "jpg";
         }
-        else if (format==="tiff") {
+        else if (format=="tiff") {
             formatAlt = "tif";
         }
 

Comments (1)

andrew 2013-09-05

Thanks for the report and fix!