]> git.lyx.org Git - lyx.git/blobdiff - src/factory.cpp
Revert 23154.
[lyx.git] / src / factory.cpp
index d5c1ddd1f676f8a29447418410054d6919f2b8a3..18bc3c18d89e5085e15d248f411e3d79e181e3be 100644 (file)
@@ -75,7 +75,7 @@ namespace lyx {
 namespace Alert = frontend::Alert;
 
 
-Inset * createInset(Buffer & buf, FuncRequest const & cmd)
+Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
 {
        BufferParams const & params = buf.params();
 
@@ -102,9 +102,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
 
                case LFUN_FLEX_INSERT: {
                        string s = cmd.getArg(0);
-                       TextClass const & tclass = params.getTextClass();
-                       InsetLayout const & il = tclass.insetlayout(from_utf8(s));
-                       return new InsetFlex(params, il);
+                       return new InsetFlex(params, params.getTextClassPtr(), s);
                }
 
                case LFUN_NOTE_INSERT: {
@@ -361,9 +359,9 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
 
        } catch (ExceptionMessage const & message) {
                if (message.type_ == ErrorException) {
+                       // This should never happen!
                        Alert::error(message.title_, message.details_);
-                       LyX::cref().emergencyCleanup();
-                       abort();
+                       LyX::cref().exit(1);
                } else if (message.type_ == WarningException) {
                        Alert::warning(message.title_, message.details_);
                        return 0;
@@ -374,6 +372,13 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
        return 0;
 }
 
+Inset * createInset(Buffer & buf, FuncRequest const & cmd)
+{
+       Inset * inset = createInsetHelper(buf, cmd);
+       if (inset)
+               inset->setBuffer(&buf);
+       return inset;
+}
 
 Inset * readInset(Lexer & lex, Buffer const & buf)
 {
@@ -385,8 +390,6 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
 
        auto_ptr<Inset> inset;
 
-       TextClass const & tclass = buf.params().getTextClass();
-
        lex.next();
        string tmptok = lex.getString();
 
@@ -480,8 +483,8 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
                } else if (tmptok == "Flex") {
                        lex.next();
                        string s = lex.getString();
-                       InsetLayout const & il = tclass.insetlayout(from_utf8(s));
-                       inset.reset(new InsetFlex(buf.params(), il));
+                       inset.reset(new InsetFlex(buf.params(), 
+                               buf.params().getTextClassPtr(), s));
                } else if (tmptok == "Branch") {
                        inset.reset(new InsetBranch(buf.params(),
                                                    InsetBranchParams()));