From c51f1cffaa186dcd73458fb589c7c2c19cac64ba Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 2 Nov 2007 17:47:51 +0000 Subject: [PATCH] * InsetCollapsable: - InsetCollapsable(): Move labelfont initialisation to InsetCollapsable::setLayout(). - read(): reset the inset layout. All other insets: get rid of redundant setLayout() calls. This commit fixes the multiple crashes in trunk but the color used for text and background are completely wrong... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21382 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetBox.cpp | 2 -- src/insets/InsetBranch.cpp | 4 ---- src/insets/InsetCollapsable.cpp | 28 ++++++++++++++++++++-------- src/insets/InsetERT.cpp | 1 - src/insets/InsetFoot.cpp | 4 +--- src/insets/InsetIndex.cpp | 4 +--- src/insets/InsetListings.cpp | 1 - src/insets/InsetMarginal.cpp | 4 +--- src/insets/InsetNote.cpp | 4 ---- 9 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 7def781ac2..ed131d5093 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -94,7 +94,6 @@ void InsetBox::init() InsetBox::InsetBox(BufferParams const & bp, string const & label) : InsetCollapsable(bp), params_(label) { - setLayout(bp); init(); } @@ -135,7 +134,6 @@ void InsetBox::read(Buffer const & buf, Lexer & lex) { params_.read(lex); InsetCollapsable::read(buf, lex); - setLayout(buf.params()); setButtonLabel(); } diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 126c8e5a16..e374f51e60 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -45,7 +45,6 @@ InsetBranch::InsetBranch(BufferParams const & bp, InsetBranchParams const & params) : InsetCollapsable(bp), params_(params) { - setLayout(bp); init(); } @@ -86,8 +85,6 @@ void InsetBranch::read(Buffer const & buf, Lexer & lex) { params_.read(lex); InsetCollapsable::read(buf, lex); - setLayout(buf.params()); - setButtonLabel(); } @@ -137,7 +134,6 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd) InsetBranchMailer::string2params(to_utf8(cmd.argument()), params); params_.branch = params.branch; setLayout(cur.buffer().params()); - setButtonLabel(); break; } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index b08e20fe44..cab612a192 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -82,14 +82,7 @@ InsetCollapsable::InsetCollapsable setDrawFrame(true); setFrameColor(Color_collapsableframe); setButtonLabel(); - // Fallback for lacking inset layout item - layout_.bgcolor = Color_background; - - // FIXME: it seems some insets don't properly initialise that! - layout_.labelfont = sane_font; - layout_.labelfont.decSize(); - layout_.labelfont.decSize(); - layout_.labelfont.setColor(Color_collapsable); + setLayout(bp); } @@ -110,7 +103,25 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs) void InsetCollapsable::setLayout(BufferParams const & bp) { + // Fallback for lacking inset layout item + layout_.bgcolor = Color_background; + + // FIXME: it seems the default background is red! layout_ = getLayout(bp); + + + // FIXME: it seems the provided font is partly realized... so we + // re-initialize the label font in any case. + /* + if (layout_.labelfont != inherit_font) + return; + */ + + // FIXME: it seems some insets don't properly initialise that... + layout_.labelfont = sane_font; + layout_.labelfont.decSize(); + layout_.labelfont.decSize(); + layout_.labelfont.setColor(Color_collapsable); } @@ -165,6 +176,7 @@ void InsetCollapsable::read(Buffer const & buf, Lexer & lex) status_ = isOpen() ? Open : Collapsed; setButtonLabel(); + setLayout(buf.params()); // Force default font, if so requested // This avoids paragraphs in buffer language that would have a diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index 0a9a3e9f86..650b7811c9 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -61,7 +61,6 @@ void InsetERT::init() InsetERT::InsetERT(BufferParams const & bp, CollapseStatus status) : InsetCollapsable(bp, status) { - setLayout(bp); init(); } diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 993e79e69f..fe15a64f92 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -36,9 +36,7 @@ using std::ostream; InsetFoot::InsetFoot(BufferParams const & bp) : InsetFootlike(bp) -{ - setLayout(bp); -} +{} InsetFoot::InsetFoot(InsetFoot const & in) diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 7a39680869..aaef4d43c5 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -30,9 +30,7 @@ using std::ostream; InsetIndex::InsetIndex(BufferParams const & bp) : InsetCollapsable(bp) -{ - setLayout(bp); -} +{} InsetIndex::InsetIndex(InsetIndex const & in) diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index fd8810a867..c43240bfe6 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -59,7 +59,6 @@ void InsetListings::init() InsetListings::InsetListings(BufferParams const & bp, InsetListingsParams const & par) : InsetCollapsable(bp, par.status()) { - setLayout(bp); init(); } diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp index 0193f5b33b..3a4ed9407d 100644 --- a/src/insets/InsetMarginal.cpp +++ b/src/insets/InsetMarginal.cpp @@ -25,9 +25,7 @@ namespace lyx { InsetMarginal::InsetMarginal(BufferParams const & bp) : InsetFootlike(bp) -{ - setLayout(bp); -} +{} InsetMarginal::InsetMarginal(InsetMarginal const & in) diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index de060487de..f6e2783474 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -116,7 +116,6 @@ InsetNote::InsetNote(BufferParams const & bp, string const & label) : InsetCollapsable(bp) { params_.type = notetranslator().find(label); - setLayout(bp); setButtonLabel(); } @@ -175,8 +174,6 @@ void InsetNote::read(Buffer const & buf, Lexer & lex) { params_.read(lex); InsetCollapsable::read(buf, lex); - setLayout(buf.params()); - setButtonLabel(); } @@ -202,7 +199,6 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) InsetNoteMailer::string2params(to_utf8(cmd.argument()), params_); // get a bp from cur: setLayout(cur.buffer().params()); - setButtonLabel(); break; case LFUN_INSET_DIALOG_UPDATE: