]> git.lyx.org Git - lyx.git/blobdiff - src/insets/Inset.cpp
Introduce BufferException so that we don't crash if a problem affects only current...
[lyx.git] / src / insets / Inset.cpp
index 8a028096deeb07c4e4321c8a16b8cce6b1e0456c..b82f264874319cce97d63cbaccb1b46f616b38f9 100644 (file)
 
 #include "support/convert.h"
 #include "support/debug.h"
+#include "support/docstream.h"
+#include "support/ExceptionMessage.h"
 #include "support/gettext.h"
 
 #include <map>
 
 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() << " name: " << name();
+               throw ExceptionMessage(BufferException, 
+                       from_ascii("Inset::buffer_ member not initialized!"), s.str());
+       }
+       return *buffer_;
 }
 
 
@@ -387,7 +386,7 @@ bool Inset::covers(BufferView const & bv, int x, int y) const
 
 InsetLayout const & Inset::getLayout(BufferParams const & bp) const
 {
-       return bp.textClass().insetLayout(name());  
+       return bp.documentClass().insetLayout(name());  
 }