From: Angus Leeming Date: Thu, 3 Jun 2004 13:08:50 +0000 (+0000) Subject: Fix crash when generating instant preview of external inset. X-Git-Tag: 1.6.10~15180 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2ca14c025aff099fb52af21785e3ba05a4c3487b;p=features.git Fix crash when generating instant preview of external inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8803 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 33e46020d8..b34a90f213 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2004-06-02 Angus Leeming + + Fix crash caused by dereferencing null pointer 'exportdata' in + OutputParams by creating a new ExportData variable on the heap, + storing it in a boost::shared_ptr. + The crash was triggered when generating an Instant Preview + of an external inset. + + * Makefile.am: add outputparams.C + + * outputparams.[Ch]: store exportdata as a shared_ptr. + (c-tor): allocate memory to it. + + * exporter.C (c-tor): associated changes. + 2004-06-01 Angus Leeming * output_linuxdoc.C (linuxdocParagraphs): Check that the paragraph diff --git a/src/Makefile.am b/src/Makefile.am index 51b46a050b..d26782ad9c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -225,6 +225,7 @@ lyx_SOURCES = \ metricsinfo.h \ output.C \ output.h \ + outputparams.C \ outputparams.h \ output_docbook.C \ output_docbook.h \ diff --git a/src/exporter.C b/src/exporter.C index f91d983855..23ada4a789 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -136,8 +136,6 @@ bool Exporter::Export(Buffer * buffer, string const & format, OutputParams runparams; runparams.flavor = OutputParams::LATEX; runparams.linelen = lyxrc.ascii_linelen; - ExportData exportdata; - runparams.exportdata = &exportdata; vector backends = Backends(*buffer); if (find(backends.begin(), backends.end(), format) == backends.end()) { for (vector::const_iterator it = backends.begin(); @@ -200,7 +198,8 @@ bool Exporter::Export(Buffer * buffer, string const & format, formats.extension(format)); // We need to copy referenced files (e. g. included graphics // if format == "dvi") to the result dir. - vector const files = exportdata.externalFiles(format); + vector const files = + runparams.exportdata->externalFiles(format); string const dest = OnlyPath(result_file); CopyStatus status = SUCCESS; for (vector::const_iterator it = files.begin(); diff --git a/src/outputparams.C b/src/outputparams.C new file mode 100644 index 0000000000..1cf785b063 --- /dev/null +++ b/src/outputparams.C @@ -0,0 +1,26 @@ +/** + * \file outputparams.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Angus Leeming + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "outputparams.h" +#include "exporter.h" + + +OutputParams::OutputParams() + : flavor(LATEX), nice(false), moving_arg(false), + free_spacing(false), use_babel(false), + mixed_content(false), linelen(0), + exportdata(new ExportData) +{} + + +OutputParams::~OutputParams() +{} diff --git a/src/outputparams.h b/src/outputparams.h index ff0fd7a9fc..7c1bc1d6fb 100644 --- a/src/outputparams.h +++ b/src/outputparams.h @@ -13,6 +13,7 @@ #define OUTPUTPARAMS_H #include "support/types.h" +#include class ExportData; @@ -26,11 +27,8 @@ struct OutputParams { XML }; - OutputParams() - : flavor(LATEX), nice(false), moving_arg(false), - free_spacing(false), use_babel(false), - mixed_content(false), linelen(0), exportdata(0) - {} + OutputParams(); + ~OutputParams(); /** The latex that we export depends occasionally on what is to compile the file. @@ -60,7 +58,7 @@ struct OutputParams { bool use_babel; /** Used for docbook to see if inside a region of mixed content. - In that case all the white spaces are significant and can not appear + In that case all the white spaces are significant and cannot appear at the begin or end. */ bool mixed_content; @@ -73,7 +71,7 @@ struct OutputParams { This is a hack: Make it possible to add stuff to constant OutputParams instances. */ - ExportData *exportdata; + boost::shared_ptr exportdata; }; -#endif // LATEXRUNPARAMS_H +#endif // NOT OUTPUTPARAMS_H