From d4cacf3642e1152af7b660a428e20f6fd7b765f3 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 28 Feb 2008 07:58:00 +0000 Subject: [PATCH] Fix crash on exit because of static dummy Buffer. * Inset::buffer(): replace dummy buffer with exception throwing. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23306 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/Inset.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index a59a0e36f3..7598271704 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -34,11 +34,14 @@ #include "support/convert.h" #include "support/debug.h" +#include "support/docstream.h" +#include "support/ExceptionMessage.h" #include "support/gettext.h" #include using namespace std; +using namespace lyx::support; namespace lyx { @@ -122,19 +125,15 @@ void Inset::setBuffer(Buffer & buffer) } -static Buffer & theDummyBuffer() -{ - static Buffer dummyBuffer("nobuffer.lyx", true); - return dummyBuffer; -} - - Buffer & Inset::buffer() { - if (buffer_) - return *buffer_; - LYXERR0("DUMMYBUFFER FOR " << lyxCode()); - return theDummyBuffer(); + if (!buffer_) { + odocstringstream s; + s << "LyX Code: " << lyxCode(); + throw ExceptionMessage(WarningException, + from_ascii("Inset::buffer_ member not initialized!"), s.str()); + } + return *buffer_; }