From 86d8e730d7f608d674b69bb433cc523a86b97743 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Sun, 28 Apr 2002 14:00:48 +0000 Subject: [PATCH] Fix bugs git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4082 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 26 +++++++++++--------------- src/ChangeLog | 5 +++++ src/insets/ChangeLog | 5 +++++ src/insets/insetfloatlist.C | 14 ++++++++------ 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index be52aba916..87f5e13afc 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -2928,23 +2928,17 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) break; case LFUN_INSET_WIDE_FLOAT: - { // check if the float type exist if (floatList.typeExist(argument)) { InsetFloat * new_inset = new InsetFloat(buffer_->params, argument); new_inset->wide(true); - if (insertInset(new_inset)) - new_inset->edit(bv_); - else - delete new_inset; + insertAndEditInset(new_inset); } else { lyxerr << "Non-existent float type: " << argument << endl; } - - } - break; + break; #if 0 case LFUN_INSET_LIST: @@ -3247,13 +3241,15 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) break; case LFUN_FLOAT_LIST: - { - // We should check the argument for validity. (Lgb) - Inset * inset = new InsetFloatList(argument); - if (!insertInset(inset, "Standard")) - delete inset; - } - break; + if (floatList.typeExist(argument)) { + Inset * inset = new InsetFloatList(argument); + if (!insertInset(inset, "Standard")) + delete inset; + } else { + lyxerr << "Non-existent float type: " + << argument << endl; + } + break; case LFUN_THESAURUS_ENTRY: { diff --git a/src/ChangeLog b/src/ChangeLog index 8faa08f87c..6613cec435 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-04-28 Dekel Tsur + + * BufferView_pimpl.C (Dispatch): Check that float type exists when + inserting list of floats. + 2002-04-24 Jean-Marc Lasgouttes * CutAndPaste.C (SwitchLayoutsBetweenClasses): when converting a diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 2f85856551..759095ec86 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2002-04-28 Dekel Tsur + + * insetfloatlist.C (getScreenLabel): Fix crash in the case where + float type do not exist. + 2002-04-26 Angus Leeming * insetfloat.C (c-tor, wide): translate the name of the float. diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index cb2785b519..7c146848c2 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -34,11 +34,11 @@ InsetFloatList::InsetFloatList(string const & type) string const InsetFloatList::getScreenLabel(Buffer const *) const { - string const guiName = floatList[getCmdName()]->second.listName(); - if (!guiName.empty()) { - return _(guiName); - } - return _("ERROR: Nonexistent float type!"); + FloatList::const_iterator it = floatList[getCmdName()]; + if (it != floatList.end()) + return _(it->second.listName()); + else + return _("ERROR: Nonexistent float type!"); } @@ -60,7 +60,9 @@ void InsetFloatList::read(Buffer const *, LyXLex & lex) if (lex.eatLine()) { setCmdName(lex.getString()); - lyxerr << "FloatList::float_type: " << getCmdName() << endl; + lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl; + if (!floatList.typeExist(getCmdName())) + lex.printError("InsetFloatList: Unknown float type: `$$Token'"); } else lex.printError("InsetFloatList: Parse error: `$$Token'"); while (lex.isOK()) { -- 2.39.5