Repository navigation
avoid accidental duplication of editing target impls - #7236
Conversation
|
This makes it much more clear what's going on and gives us a straighter line from the function call to the object we like. Thank you! Are we able to also push this into Water Lily for the release or would you prefer to keep it a v1.4 fix? Thoughts @jmcphers ? |
jmcphers
left a comment
There was a problem hiding this comment.
This LGTM but is a little scary to take for 1.3. Do we know why 1.3 (and 1.3 only, not 1.1, 1.2, or 1.4) repros bug #7066? I'm wondering if the fact that this isn't broken everywhere suggests that there is something much simpler we could change that would work around the issue without this more fundamental change. If this is indeed the simplest change then I think we should hold off until Giant Goldenrod.
Also wonder if we should create our own version of Provider<T> that caches the object for the first get() and serves it for subsequent get() invocations so we have a generalized approach to this problem.
|
I just tried porting this change locally to v1.3 and while it fixes the exception here it doesn't actually fix the issue with the data viewer failing to update. 😞 At least that signals that this is safe to take for v1.4 and ignore for v1.3 (since something else must be going on there) |
Definitely agree this is worth doing. I'll file a separate v1.4 issue for this. |
|
Ok if this doesn't actually fix the DataViewer updating then something else is going on (likely after the exception), and probably something I can now more easily debug and fix. I propose that we get this change into Giant Goldenrod and I'll fix #7066 in there since I think this exception is blocking the underlying issue at the moment. I'm cherry-picking this commit into Water Lily right now and seeing if my original theories about the updating are correct. |
👍 |
|
Great thanks, I'll move it the bug milestone and cherry pick this change into GG when we start building it. |
|
I'll merge this to master for now -- @adamconroy feel free to cherry-pick after. |
This PR fixes a somewhat long-standing issue, where calling
getDefaultNamePrefix()could cause the instantiation of a separate, standalone EditingTarget; separate from the one actually used. See #7066 (comment) for extra investigation.If I understand correctly, the assumption we were making was that, for a single
Provider<Foo> fooinstance, callingfoo.get()would return a reference to the sameFooinstance. This appears to not be the case; each invocation ofget()may return a reference to a separate instance entirely.We resolve this issue by de-coupling name provision from the editing target source class. Instead, we create a simple interface that takes an EditingTarget, and returns a default name prefix given that target. That interface can then just delegate back to
target.getDefaultNamePrefix(), which helps ensure that we're using the same already-initialized target as opposed to a separate instance provided by dependency injection.