Angus Leeming <[EMAIL PROTECTED]> writes:
| Lars Gullik Bj�nnes wrote:
>
>> One of the places I was a bit eager it seems.
>>
>> renderer_.reset(new RenderButton);
>> button_ptr = renderer_->asButton();
>>
>> would perhaps be nicest.
>
| Ah yes. I'd forgotten I'd introduced those asFooBar() thingies ;-)
>
>> similar here.
>>
>> auto_ptr<RenderMonitoredPreview>
>> rmp(new RenderMonitoredPreview);
>> rmp->connect(boost::bind(&InsetExternal::statusChanged,
>> this)); rmp->fileChanged(...
>> renderer_.reset(rmp);
>> preview_ptr = renderer_->asMonitoredPreview();
>>
>> I do not find these ugly then...
>
| Much less so. However, I prefer the idea of storing the ptr
| immediately and then accessing it asMonitoredPreview().
>
| renderer_.reset(new RenderMonitoredPreview);
| RenderMonitoredPreview * preview_ptr =
| renderer_->asMonitoredPreview();
| preview_ptr->connect(boost::bind(&InsetExternal::statusChanged,
| this));
>
| No need to change the store from scoped_ptr after all.
I concur, I made those changes in my code.
If you see other places that needs the same cleanup, please yell.
The main idea behind the patch is to never do operations on a bald
pointer, in particual operation that might throw. (and that is almost
all operations).
So basically the only thing you are allowed to do with a bald pointer
is to store it somewhere safe: auto_ptr, scoped_ptr, shared_ptr,
MathAtom etc.
--
Lgb