From 265327763d69ade5329e22987664f7ab78ee458b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 24 Apr 2003 20:02:49 +0000 Subject: [PATCH] Bug: 1074 Fix some insertion of empty insets stuff. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6847 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 12 ++++++++++++ src/insets/insetcommand.C | 3 +++ src/insets/insetexternal.C | 5 ++++- src/insets/insetfloat.C | 3 +++ src/insets/insetgraphics.C | 5 ++++- src/insets/insetgraphics.h | 2 +- src/insets/insetinclude.C | 15 +++++++++------ src/insets/insetminipage.C | 3 +++ src/insets/insettabular.C | 4 ++++ src/insets/insetwrap.C | 3 +++ 10 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 39e07ca371..24d2d9fa5e 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,15 @@ +2003-04-24 Lars Gullik Bjønnes + + * insetexternal.C (string2params): dont do anything if the string + is empty. + * insetgraphics.C (string2params): ditto + * insetcommand.C (string2params): ditto + * insetert.C (string2params): ditto + * insetfloat.C (string2params): ditto + * insetinclude.C (string2params): ditto + * insetminipage.C (string2params): ditto + * insettabular.C (string2params): ditto + * insetwrap.C (string2params): ditto 2003-04-24 André Pönitz diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index a92eb06e6d..debea3f0a4 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -121,6 +121,9 @@ void InsetCommandMailer::string2params(string const & in, params.setContents(string()); params.setOptions(string()); + if (in.empty()) + return; + istringstream data(in); LyXLex lex(0,0); lex.setStream(data); diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 54107b1501..82db5c2ce4 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -382,6 +382,9 @@ void InsetExternalMailer::string2params(string const & in, { params = InsetExternal::Params(); + if (in.empty()) + return; + istringstream data(in); LyXLex lex(0,0); lex.setStream(data); @@ -403,7 +406,7 @@ void InsetExternalMailer::string2params(string const & in, } if (lex.isOK()) { - InsetExternal inset; + InsetExternal inset; inset.read(0, lex); params = inset.params(); } diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 841b41943a..4b4e8202ba 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -401,6 +401,9 @@ void InsetFloatMailer::string2params(string const & in, { params = InsetFloatParams(); + if (in.empty()) + return; + istringstream data(in); LyXLex lex(0,0); lex.setStream(data); diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 0f4d367bb0..4582781cfe 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -896,6 +896,9 @@ void InsetGraphicsMailer::string2params(string const & in, { params = InsetGraphicsParams(); + if (in.empty()) + return; + istringstream data(in); LyXLex lex(0,0); lex.setStream(data); @@ -908,7 +911,7 @@ void InsetGraphicsMailer::string2params(string const & in, } if (lex.isOK()) { - InsetGraphics inset; + InsetGraphics inset; inset.readInsetGraphics(lex); params = inset.params(); } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 03a1884bcc..868f6d623e 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -35,7 +35,7 @@ public: /// ~InsetGraphics(); /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); + virtual dispatch_result localDispatch(FuncRequest const & cmd); /// int ascent(BufferView *, LyXFont const &) const; /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index a69245f07d..90ed386307 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -177,7 +177,7 @@ void InsetInclude::set(Params const & p) params_ = p; string command; - + switch (params_.flag) { case INCLUDE: command="include"; @@ -192,9 +192,9 @@ void InsetInclude::set(Params const & p) command="verbatiminput*"; break; } - - params_.cparams.setCmdName(command); - + + params_.cparams.setCmdName(command); + if (preview_->monitoring()) preview_->stopMonitoring(); @@ -306,7 +306,7 @@ bool InsetInclude::loadIfNeeded() const if (!finfo.isOK()) return false; - return bufferlist.loadLyXFile(getFileName(), false) != 0; + return bufferlist.loadLyXFile(getFileName(), false) != 0; } @@ -641,6 +641,9 @@ void InsetIncludeMailer::string2params(string const & in, { params = InsetInclude::Params(); + if (in.empty()) + return; + istringstream data(in); LyXLex lex(0,0); lex.setStream(data); @@ -662,7 +665,7 @@ void InsetIncludeMailer::string2params(string const & in, } if (lex.isOK()) { - InsetInclude inset(params); + InsetInclude inset(params); inset.read(0, lex); params = inset.params(); } diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 892473647d..a5046430b6 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -375,6 +375,9 @@ void InsetMinipageMailer::string2params(string const & in, { params = InsetMinipage::Params(); + if (in.empty()) + return; + istringstream data(in); LyXLex lex(0,0); lex.setStream(data); diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 3c41f35187..f4a46d7177 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2927,6 +2927,10 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset) LyXLex lex(0,0); lex.setStream(data); +#warning CHECK verify that this is a sane value to return. + if (in.empty()) + return -1; + if (lex.isOK()) { lex.next(); string const token = lex.getString(); diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 5fd53c41d6..11c3417182 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -301,6 +301,9 @@ void InsetWrapMailer::string2params(string const & in, { params = InsetWrapParams(); + if (in.empty()) + return; + istringstream data(in); LyXLex lex(0,0); lex.setStream(data);