Closed
Bug 649024
Opened 14 years ago
Closed 14 years ago
Make XPCOMUtils.defineLazyGetter retry if the function originally threw an exception
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: glandium, Unassigned)
Details
Attachments
(1 file)
|
892 bytes,
patch
|
Details | Diff | Splinter Review |
Currently, if the function defined as a lazy getter fails, the property ends up undefined. I think it would be better to make it retry (though I actually haven't checked if that leads to something unexpected in callers)
I'm wondering if removing the "delete aObject[aName];" shouldn't be enough, but I'm not sure what kind of side effect that would have on garbage collection.
Attachment #525086 -
Flags: review?(benjamin)
Comment 1•14 years ago
|
||
Removing the delete would have no effect on GC, but it would make the set not do anything, of course.
| Reporter | ||
Comment 2•14 years ago
|
||
(In reply to comment #1)
> Removing the delete would have no effect on GC, but it would make the set not
> do anything, of course.
Oh, so a property with a getter but no setter can't be overridden without being removed first. Kind of makes sense.
Updated•14 years ago
|
Attachment #525086 -
Flags: review?(benjamin) → review?(sdwilsh)
Comment 3•14 years ago
|
||
Hmm, so the contact we've kinda had with this is that the callback would only ever be called once. What issue have you hit that makes you want this change?
| Reporter | ||
Comment 4•14 years ago
|
||
See the startupInfo getter in https://addons.mozilla.org/en-US/firefox/files/browse/117663 and the saveData function in https://addons.mozilla.org/en-US/firefox/files/browse/117663
That's probably a very limited use-case, and I could do without modifying XPCOMUtils.defineLazyGetter, but I thought it could be useful.
Comment 5•14 years ago
|
||
(In reply to comment #4)
> See the startupInfo getter in
> https://addons.mozilla.org/en-US/firefox/files/browse/117663 and the saveData
> function in https://addons.mozilla.org/en-US/firefox/files/browse/117663
> That's probably a very limited use-case, and I could do without modifying
> XPCOMUtils.defineLazyGetter, but I thought it could be useful.
I think it would be better if we didn't retry it. Do we at least do something useful and report an error by chance?
(also, eww, _data does synchronous disk I/O)
| Reporter | ||
Comment 6•14 years ago
|
||
(In reply to comment #5)
> (In reply to comment #4)
> > See the startupInfo getter in
> > https://addons.mozilla.org/en-US/firefox/files/browse/117663 and the saveData
> > function in https://addons.mozilla.org/en-US/firefox/files/browse/117663
> > That's probably a very limited use-case, and I could do without modifying
> > XPCOMUtils.defineLazyGetter, but I thought it could be useful.
> I think it would be better if we didn't retry it. Do we at least do something
> useful and report an error by chance?
In that case, the startup info may be incomplete if you get it too early, and we want to save all of it, so it's retried until it is complete, at which point it is cached.
So in the more common case, it would be up to the caller to do error reporting if it wants to.
> (also, eww, _data does synchronous disk I/O)
it's only used when displaying the about:startup page, which needs these contents.
Comment 7•14 years ago
|
||
Are you OK with rolling your own cached getter since your use case is a bit special?
| Reporter | ||
Comment 8•14 years ago
|
||
(In reply to comment #7)
> Are you OK with rolling your own cached getter since your use case is a bit
> special?
I'm entirely ok with it. cf. comment 4. Feel free to WONTFIX.
Comment 9•14 years ago
|
||
That's what I'll do. Thanks for raising the issue though; happy to at least consider stuff like this :)
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
Updated•14 years ago
|
Attachment #525086 -
Flags: review?(sdwilsh)
You need to log in
before you can comment on or make changes to this bug.
Description
•