]> git.lyx.org Git - features.git/commitdiff
Fix crash when generating instant preview of external inset.
authorAngus Leeming <leeming@lyx.org>
Thu, 3 Jun 2004 13:08:50 +0000 (13:08 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 3 Jun 2004 13:08:50 +0000 (13:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8803 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/Makefile.am
src/exporter.C
src/outputparams.C [new file with mode: 0644]
src/outputparams.h

index 33e46020d83f5aab70cc47b33c33baace53edc9a..b34a90f213972686e9dfcb8655338d9f0ba4a9ae 100644 (file)
@@ -1,3 +1,18 @@
+2004-06-02  Angus Leeming  <leeming@lyx.org>
+
+       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<Exportdata>.
+       (c-tor): allocate memory to it.
+
+       * exporter.C (c-tor): associated changes.
+
 2004-06-01  Angus Leeming  <leeming@lyx.org>
 
        * output_linuxdoc.C (linuxdocParagraphs): Check that the paragraph
index 51b46a050b2df4faefd49aed43c8de9e75b9c6e0..d26782ad9c6e965551468dcfe7087e811d75a7c4 100644 (file)
@@ -225,6 +225,7 @@ lyx_SOURCES = \
        metricsinfo.h \
        output.C \
        output.h \
+       outputparams.C \
        outputparams.h \
        output_docbook.C \
        output_docbook.h \
index f91d98385558635e551022a38ea9cc548f68a1bc..23ada4a7891c4a9813aa52e6c2252b10f983008d 100644 (file)
@@ -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<string> backends = Backends(*buffer);
        if (find(backends.begin(), backends.end(), format) == backends.end()) {
                for (vector<string>::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<ExportedFile> const files = exportdata.externalFiles(format);
+               vector<ExportedFile> const files =
+                       runparams.exportdata->externalFiles(format);
                string const dest = OnlyPath(result_file);
                CopyStatus status = SUCCESS;
                for (vector<ExportedFile>::const_iterator it = files.begin();
diff --git a/src/outputparams.C b/src/outputparams.C
new file mode 100644 (file)
index 0000000..1cf785b
--- /dev/null
@@ -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 <config.h>
+
+#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()
+{}
index ff0fd7a9fc3fe62b2e350d470d1fc5aac25ef721..7c1bc1d6fbc587de2f2bfb12e874e88b20d1f1d1 100644 (file)
@@ -13,6 +13,7 @@
 #define OUTPUTPARAMS_H
 
 #include "support/types.h"
+#include <boost/shared_ptr.hpp>
 
 
 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> exportdata;
 };
 
-#endif // LATEXRUNPARAMS_H
+#endif // NOT OUTPUTPARAMS_H