Lars Gullik Bjønnes wrote:
> I do like this better.
>
> Would anything change if you used exceptions to handle the case?
> No need to return 0 from newFile? would it make anything simpler, or
> just more complicated?
I think it would make things more complicated, because we know at every
place where newFile is called what to do if it failed. Exceptions would
only add line noise in this case. They would be useful if we needed to
catch them somewhere else.
I will commit the second patch now.
Georg
Log:
Fix bug 2404
* src/lyx_cb.C
(newFile): Only set the new buffer if it is valid
* src/BufferView_pimpl.C
(BufferView::Pimpl::loadLyXFile): Test whether newFile succeeded
* src/lyxfunc.C
(LyXFunc::menuNew): Only set the new buffer if it is valid
(LyXFunc::open): ditto
* src/importer.C
(Importer::Import): ditto
* src/lyx_main.C
(LyX::exec2): Only use the new buffer if newFile succeeded
* src/buffer_funcs.C
(newFile): discard the buffer and return 0 if the template is invalid