pencil icon indicating copy to clipboard operation
pencil copied to clipboard

Can't open ep file

Open rubensa opened this issue 4 years ago • 4 comments

  • Operating system: Ubuntu 18.04
  • Pencil version: 3.1.0

I can't open an ep file. Nothing shows in the application.

Using debugger I can see the following exception when iterating pages in function parseNextPageNode(__callback) from EpHandler.prototype.parseOldFormatDocument

TypeError: this.invalidateBrokenImageRefs is not a function
    at file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/controller.js:486:18
    at Object.Dom.workOn (file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/util.js:434:9)
    at Controller.invalidateContentNode (file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/controller.js:470:9)
    at EpHandler.FileHandler.parsePageFromNode (file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/FileHandler.js:217:25)
    at parseNextPageNode (file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/EpHandler.js:39:18)
    at file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/EpHandler.js:40:17
    at file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/FileHandler.js:220:13
    at runNextValidation (file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/controller.js:461:13)
    at file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/controller.js:466:13
    at file:///opt/pencil-3.1.0.ga/resources/default_app.asar/pencil-core/common/controller.js:453:17

rubensa avatar Jan 20 '20 11:01 rubensa

Could this be related to this usage inside a Dom.workOn?:

cotroller.js (line 470)

    Dom.workOn("//svg:g[@p:type='Shape']", node, function (shapeNode) {
        var defId = shapeNode.getAttributeNS(PencilNamespaces.p, "def");
        var def = CollectionManager.shapeDefinition.locateDefinition(defId);
        
        if (def) {
            Dom.workOn("./p:metadata/p:property", shapeNode, function (propertyNode) {
                var name = propertyNode.getAttribute("name");
                var propertyDef = def.propertyMap[name];
                if (!propertyDef || !propertyDef.type.invalidateValue) return;
                var type = propertyDef.type;

                invalidateTasks.push(createInvalidationTask(type, name, propertyNode));

            });
        } else {
            // Adhoc invalidation for rasterized image reference from within missing shapes
            this.invalidateBrokenImageRefs(shapeNode);
        }
        
    });

rubensa avatar Jan 20 '20 11:01 rubensa

Missing .bind(this)?

rubensa avatar Jan 20 '20 11:01 rubensa

I changed (using debugger):

    Dom.workOn("//svg:g[@p:type='Shape']", node, function (shapeNode) {
        var defId = shapeNode.getAttributeNS(PencilNamespaces.p, "def");
        var def = CollectionManager.shapeDefinition.locateDefinition(defId);
        
        if (def) {
            Dom.workOn("./p:metadata/p:property", shapeNode, function (propertyNode) {
                var name = propertyNode.getAttribute("name");
                var propertyDef = def.propertyMap[name];
                if (!propertyDef || !propertyDef.type.invalidateValue) return;
                var type = propertyDef.type;

                invalidateTasks.push(createInvalidationTask(type, name, propertyNode));

            });
        } else {
            // Adhoc invalidation for rasterized image reference from within missing shapes
            this.invalidateBrokenImageRefs(shapeNode);
        }
        
    });

with:

    Dom.workOn("//svg:g[@p:type='Shape']", node, function (shapeNode) {
        var defId = shapeNode.getAttributeNS(PencilNamespaces.p, "def");
        var def = CollectionManager.shapeDefinition.locateDefinition(defId);
        
        if (def) {
            Dom.workOn("./p:metadata/p:property", shapeNode, function (propertyNode) {
                var name = propertyNode.getAttribute("name");
                var propertyDef = def.propertyMap[name];
                if (!propertyDef || !propertyDef.type.invalidateValue) return;
                var type = propertyDef.type;

                invalidateTasks.push(createInvalidationTask(type, name, propertyNode));

            });
        } else {
            // Adhoc invalidation for rasterized image reference from within missing shapes
            this.invalidateBrokenImageRefs(shapeNode);
        }
        
    }.bind(this));

and now, the file is loaded.

rubensa avatar Jan 20 '20 11:01 rubensa

use arrow function also be the same feature

dwatow avatar May 30 '22 05:05 dwatow