Il 15/09/2011 03:54, Richard Heck ha scritto:
I get an assertion at line 192 of RenderPreview.cpp. I take it the problem is that, without a GUI, we do not have a PreviewLoader, which is what I use to create math images. I'll have to figure out what to do about this.
The attached patch gets rid of the crash in this case. Please, check how it seems. The PreviewLoader is created always on demand, independently of the LyxRC settings (which are probably influenced by the use_gui boolean someway). However, when invoking Buffer::loader(), I tried to check before the invocation whether preview is active or not (actually, I had to change only one place), as opposed to calling
it and checking whether it returned 0. T.
Index: src/insets/RenderPreview.cpp =================================================================== --- src/insets/RenderPreview.cpp (revisione 39684) +++ src/insets/RenderPreview.cpp (copia locale) @@ -80,6 +80,7 @@ Buffer const & buffer = bv->buffer(); graphics::PreviewLoader const * loader = buffer.loader(); + LASSERT(loader, /**/); graphics::PreviewLoader::Status const status = loader->status(snippet); docstring message; Index: src/LyX.cpp =================================================================== --- src/LyX.cpp (revisione 39684) +++ src/LyX.cpp (copia locale) @@ -312,6 +312,9 @@ // something interesting about the locale directory. Messages::init(); + // Let the frontend parse and remove all arguments that it knows + pimpl_->application_.reset(createApplication(argc, argv)); + if (!use_gui) { // FIXME: create a ConsoleApplication int exit_status = init(argc, argv); @@ -348,9 +351,6 @@ return !final_success; } - // Let the frontend parse and remove all arguments that it knows - pimpl_->application_.reset(createApplication(argc, argv)); - // Reestablish our defaults, as Qt overwrites them // after createApplication() locale_init(); Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (revisione 39684) +++ src/Buffer.cpp (copia locale) @@ -954,8 +954,6 @@ PreviewLoader * Buffer::loader() const { - if (lyxrc.preview == LyXRC::PREVIEW_OFF) - return 0; if (!d->preview_loader_) d->preview_loader_ = new PreviewLoader(*this); return d->preview_loader_; @@ -971,9 +969,10 @@ void Buffer::updatePreviews() const { - PreviewLoader * ploader = loader(); - if (!ploader) + if (lyxrc.preview == LyXRC::PREVIEW_OFF) return; + PreviewLoader * ploader = loader(); + LASSERT(ploader, /**/); InsetIterator it = inset_iterator_begin(*d->inset); InsetIterator const end = inset_iterator_end(*d->inset);