From 090bd44740a1de825ebdd9c4168a9b998a55214c Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 6 Aug 2014 11:43:22 -0400 Subject: [PATCH] Fix bug #9236: After we recreate the DocumentClass, we have to apply it to the document. (cherry picked from commit c2fdbbe01aa4f6c65bcfe391326ff35b8c6d219e) --- src/frontends/qt4/GuiApplication.cpp | 14 ++++++++++++++ status.21x | 1 + 2 files changed, 15 insertions(+) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 22c129b350..b4960b2094 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -32,9 +32,12 @@ #include "Buffer.h" #include "BufferList.h" +#include "BufferParams.h" #include "BufferView.h" #include "CmdDef.h" #include "Color.h" +#include "CutAndPaste.h" +#include "ErrorList.h" #include "Font.h" #include "FuncRequest.h" #include "FuncStatus.h" @@ -54,6 +57,8 @@ #include "Thesaurus.h" #include "version.h" +#include "insets/InsetText.h" + #include "support/convert.h" #include "support/debug.h" #include "support/ExceptionMessage.h" @@ -1914,7 +1919,16 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) istringstream ss(argument); Lexer lex; lex.setStream(ss); + + // See #9236 + // We need to make sure that, after we recreat the DocumentClass, + // which we do in readHeader, we apply it to the document itself. + DocumentClassConstPtr olddc = defaults.params().documentClassPtr(); int const unknown_tokens = defaults.readHeader(lex); + DocumentClassConstPtr newdc = defaults.params().documentClassPtr(); + ErrorList el; + InsetText & theinset = static_cast(defaults.inset()); + cap::switchBetweenClasses(olddc, newdc, theinset, el); if (unknown_tokens != 0) { lyxerr << "Warning in LFUN_BUFFER_SAVE_AS_DEFAULT!\n" diff --git a/status.21x b/status.21x index 4bd5f6970e..3c5957883c 100644 --- a/status.21x +++ b/status.21x @@ -67,6 +67,7 @@ What's new - Fix import of latex documents with scaled fonts. +- Fix crash when saving default template (bug 9236). * LYX2LYX -- 2.39.5