Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for deep state check and save #3262

Merged
merged 6 commits into from
Sep 15, 2016
Merged

allow for deep state check and save #3262

merged 6 commits into from
Sep 15, 2016

Conversation

asturur
Copy link
Member

@asturur asturur commented Sep 14, 2016

SaveState and hasStateChanged work on a simple equality and reference storage.
So storing a fill color is ok, storying an array of values ( transformMatrix, textDecoration ) is not.

This Pr enable for deeper checks, Fixes a bug in wich additional state properties where not check during hasStateChanged and extend the merge ( and clone ) util with deep option.

@asturur asturur merged commit 437eea1 into master Sep 15, 2016
@asturur asturur deleted the deepSaveState branch September 15, 2016 10:49
asturur added a commit that referenced this pull request Sep 17, 2016
* fixed selection, added test (#3254)

* allow for deep state check and save (#3262)

* added fill for images

* added fill for images

* added fill for images

* fix tests
@eschnabel
Copy link

I have updated to 1.6.5 (and now 1.6.6) and we have an object that extends Line and then includes a shadow. When the shadow is added this new deep state clone stuff fails in a stack overflow and breaks everything for us. If I change the deep = true to deep = false, it works. Is there some way for us to configure this outside of fabric? Is there something that would cause this endless loop?

@Rad1calDreamer
Copy link

+1 to previous

@asturur
Copy link
Member Author

asturur commented Nov 15, 2016

did not get this notice. Giving a look to this. sorry i released 1.6.7 just 2 days ago.

@asturur
Copy link
Member Author

asturur commented Nov 15, 2016

I have a question, are you using stateful = true?
Since some version stateful true is sort of useless unless you are using it for your custom code.
So as an immediate solution try to start the canvas with stateful = false and i m looking this now.

@Rad1calDreamer
Copy link

i use stateful:false in my app

@Rad1calDreamer
Copy link

Rad1calDreamer commented Nov 15, 2016

this.canvas.forEachObject(function(obj) {
            if (!obj.id) {
               var _obj2 = obj.toObject(['x1', 'y1', 'x2', 'y2', 'objID', 'selectable']),
                  _obj;
               if (obj.type === 'path') {
                  _obj = new fabric.Path.fromObject(_obj2, function(foo) {
                        _tmpCanvas.add(foo);
                     }
                  );
               } else {
                  _obj =
                     new fabric [fabric.util.string.camelize(fabric.util.string.capitalize(obj.type))].fromObject(_obj2);
                  _tmpCanvas.add(_obj);
               }

            }
         });

that code. If some of objects have shadow -> extend function gooing to maximum stack call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants