Skip to content

reset doesn't work for shared objects #43

@weefuzzy

Description

@weefuzzy

The reset message is broken for shared objects (fluid.dataset~ and friends). The intended behaviour is that an object will revert to the state of its defaults, modulo what values were set in the box at instantiation time.

Patch to reproduce

----------begin_max5_patcher----------
652.3ocyWt0jZBCE.9Y3WQFdl5PB26S6+iN6rSDitYKDrIAqs6r82dyEQocY
oHnVeAMGOgy46bKwWcc7VVumH7.eF7EfiyqtNNFQZANGV63Ug2WThEF07Jpq
pHLomu82jj8RibFdEtUHqohxJIRyNfmDV2HakFbPJckY20Ke4Svr18uEKKdl
x17DmTHsNGJIcQfO.kko+.FGXVodBdTum2bc0O7mIDU3uR.XPwyX1FxLoIcD
zDkeMoQ9LU.3DYCmI.xZ.kQkfc3xFh.fE.x9sJGhrBztwRJiTT2vL6F058bh
P8xwRZM6od0Xhwm3AhOvbSDAFD2I9DFdGmsiFhlTj1+SCtDI6JhPfO4tGgQm
lj8BApWHf8.Apc+V8j+XKwRfmG3wA3Cla6MSLoISNCgtv7sTaWA8mDUnyGTR
vbFGKIffEvYRMbhTGDrH11CGeJsNUrYjuqbl2Q85xF5pEUkptvMpLrnl+KvC
cgOD7voHSbvfsxinzN78wmzOL7rT0234qcxZrT+kwTkDlYKVfn1hk6s1fjIV
ODl0Yl0LKG9H7T7rlS9FHJXdLFMMFygmFjkDe8J3W1rtZcQgpVuEXz0nzFdo
JsismSklXq.BlUoMVJ4Mzy37ndxuiYRt1NcKp792.FE18HLz+Q.yNG.ONgbH
DCsCjPY2KHleNHd7LgQfXb9PHZd2ltr+5+EXdiZ4+I2h5FdQqm0dMBPvQWbE
QHoLy8G6nTpUmdCsi1PvajgxuQ1I6FYmjQXG3EvNQ2H6fljcrE53sa2Q3hCJ
aLgpU9kZSaUluYIkYWZZRUWwXGsUenUDlq50jpFsFtwu71mXOg0qpdEgyTiB
zJ6poSYSybBFVcH+VrEDy3D22b+MP8Un7C
-----------end_max5_patcher-----------

I think this is because I didn't consider that for shared objects we are now dealing with reference semantics for the params, and so the the snapshot we take at instantiation time is effectively a pointer 🤦 Rather than start with making arcane assignment operators for the shared params, I think the neatest solution here is to change the overall behaviour to take advantage of the from/toTuple methods recently introduced, and keep the snapshots as tuples. This means that we can rely on parameter updates propagating properly when reset is called.

There is, of course, the potential for confusion here when multiple boxes pointing to the same name init with different params. However, I think the simple approach is the one to follow here, which is that the late bird gets the worm. i.e. each box still stores its own values, and the last one wins.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions