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

closebang bug fixes #596

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Spacechild1
Copy link
Contributor

@Spacechild1 Spacechild1 commented Apr 26, 2019

  • send closebangs before any object is actually removed and in the same order as loadbang and initbang:
  1. abstractions / clone objects (recursively)
  2. subpatches (recursively)
  3. remaining objects on the canvas

the current ordering is messy because when an object receives a closebang, other objects might have already been destroyed. so if you want to save a table with [closebang] for example, you have to put it into the right place in the glist (the details are complicated). here's a patch which demonstrates the problem:
closebang-issue.zip
what I would want instead is that no object is actually deleted unless all closebang messages have been sent, so I don't have worry about where I put my [closebang] objects.

  • don't send closebang twice to cloned abstractions

  • fix a bug where non-canvas objects on the root canvas wouldn't receive a closebang message.


externals which use glist_delete from the private canvas API still work as expected.
the [clear( message also works.
cutting objects is ok but canvas_closebang is called on every selected canvas in series - which means the closebang order is only correct for each selected canvas. otoh, it's the same with loadbang and initbang when pasting multiple canvases, so at least its consistent. later we might want to fix the initialization order for cut&paste...

here's a test patch (needs [iemguts] with a version before 2018):
closebang-test.zip

needs review from @umlaeute (see also https://git.iem.at/pd/iemguts/issues/8)

@umlaeute umlaeute self-assigned this Apr 28, 2019
@Spacechild1
Copy link
Contributor Author

@umlaeute gentle reminder ;-)

@umlaeute umlaeute self-requested a review December 3, 2019 22:06
@Spacechild1
Copy link
Contributor Author

Spacechild1 commented Jul 13, 2021

@umlaeute if you have time, it would be great if you could have a look, since this PR is mainly aimed at [iemguts/closebang].

Copy link
Contributor

@umlaeute umlaeute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine by me.

@millerpuckette
Copy link
Contributor

Would it work to change canvas_loadbang(t_canvas *x) to canvas_loadbang(t_canvas *x, t_floatarg action) where
acvtion can be LB_LOAD or LB_CLOSE? Then canvas_free could just blithely call canvas_loadbang(x, LB_CLOSE) and we could tell anyone wanting to catch the CLOSE message that it can happen multiple times but just ignore all but the first one you get.

@Spacechild1
Copy link
Contributor Author

We can't really send the "closebang" from within canvas_free because it would mess up the ordering, as explained in the PR description. Most importantly, I make sure that all "closebangs" are sent before any objects are actually deleted, just like "loadbangs" are sent after all objects have been created.

@Spacechild1 Spacechild1 force-pushed the closebang-fix branch 2 times, most recently from 6017ffe to 2eedd44 Compare October 18, 2021 20:58
@millerpuckette
Copy link
Contributor

I think this should be done differently by writing a unifying function that can recurse into all patces/subpatches with options to go depth-first and/or cancel going into abstractions/clones and/or only report the first one after a given match and perhaps others as needed to support find, loadbang, closebang, and all that. I'm afraid that putting features in piecemeal for 0.52 will make that harder to do compatibly in the future, so I propose to try to get this running after 0.52 goes out (hopefully ready to 'test' very soon).

@Spacechild1
Copy link
Contributor Author

Ok! I'll keep this PR open just as a reference for the "correct" closebang behavior. Once you've implemented your solution, it can be closed.

@Spacechild1
Copy link
Contributor Author

I'm afraid that putting features in piecemeal for 0.52 will make that harder to do compatibly in the future, so I propose to try to get this running after 0.52 goes out (hopefully ready to 'test' very soon).

On a second thought, unified canvas traversal is just an implementation detail, the actual feature (= behavior) would be the same. So I don't really understand what you mean by "putting features in piecemeal".

Specifically, if you merge this PR, you would later only need to change the implementation of canvas_closebang, just like canvas_loadbang and canvas_initbang. The function itself, however, would already be called at the right places - which is the actual tricky part.

I think it could be helpful to have the right behavior in place before doing all the refactoring. But that's just my opinion. Do whatever you feel more comfortable with :-)

@umlaeute umlaeute added bug/fix either a bug (for issues) or a bugfix (for pull-requests) subject:core things concerning the Pd-core labels Sep 5, 2022
@Spacechild1 Spacechild1 closed this Apr 2, 2024
@Spacechild1 Spacechild1 reopened this Apr 2, 2024
Spacechild1 and others added 7 commits April 2, 2024 19:46
this makes sure that closebang is called in the same sequence as loadbang (and initbang)
…itly requested

the original glist_delete() is now a wrapper around glist_dodelete() which calls canvas_closebang().
this is done to maintain backwards compatibility with existing externals which use the private canvas API.
… want to emit a closebang (again):

* graph_delete (a subpatch is deleted)
* canvas_free (a root canvas/abstraction is freed)
when a root canvas is closed, we want to send a closebang to all children, in the same order as loadbang.
this also fixes a bug where [iemguts/closebang] wouldn't work on the toplevel root canvas.
instead emit the closebangs in glist_delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/fix either a bug (for issues) or a bugfix (for pull-requests) subject:core things concerning the Pd-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants