Am Sonntag, 8. Mai 2005 11:26 schrieb Asger Ottar Alstrup:
> Maybe you could add some comments about what the protocol for 
> update/noupdate calls is? Add it to the BufferView::update method, or 
> wherever the main update call is.

There is already a comment in LCursor::dispatch. In fact I got my 
knowledge from there :-) I added a more detailed one to 
InsetBase::doDispatch(), because this is the place where inset developers 
look.

> In general, I think the new code should be commented some more. Maybe 
> you do not understand exactly how it is supposed to work, but it is 
> still better to add a comment about how you understand it than not 
> adding something. Then, the people that understand it can post patches 
> to the comments.

I agree, and I added comments whenever I found it appropriate in the past.

I am going to commit the attached version of nobody objects.


Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/ChangeLog lyx-1.4-cvs/src/insets/ChangeLog
--- lyx-1.4-clean/src/insets/ChangeLog	2005-05-08 11:59:27.000000000 +0200
+++ lyx-1.4-cvs/src/insets/ChangeLog	2005-05-08 12:41:25.000000000 +0200
@@ -1,3 +1,11 @@
+2005-05-08  Georg Baum  <[EMAIL PROTECTED]>
+
+	* insetbase.h (doDispatch): document a bit more
+	* insetcommand.C, insetfloat.C, insetgraphics.C, insetinclude.C,
+	insetnote.C, insetwrap.C, updatableinset.C (doDispatch): don't call
+	cur.bv().update(), because that leads to nested updates. Call
+	cur.noUpdate() instead where approriate.
+
 2005-05-07  Michael Schmitt  <[EMAIL PROTECTED]>
 
 	* insetbibtex.C: change screen label
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetbase.h lyx-1.4-cvs/src/insets/insetbase.h
--- lyx-1.4-clean/src/insets/insetbase.h	2005-04-23 10:15:04.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insetbase.h	2005-05-08 12:27:43.000000000 +0200
@@ -402,8 +406,17 @@ public:
 protected:
 	InsetBase();
 	InsetBase(InsetBase const &);
-	/// the real dispatcher.
-	/// \sa getStatus
+	/** The real dispatcher.
+	 *  Gets normally called from LCursor::dispatch(). LCursor::dispatch()
+	 *  assumes the common case of 'LFUN handled, need update'.
+	 *  This has to be overriden by calling LCursor::undispatched() or
+	 *  LCursor::noUpdate() if appropriate.
+	 *  If you need to call the dispatch method of some inset directly
+	 *  you may have to explicitly request an update at that place. Don't
+	 *  do it in doDispatch(), since that causes nested updates when
+	 *  called from LCursor::dispatch(), and these can lead to crashes.
+	 *  \sa getStatus
+	 */
 	virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
 private:
 	virtual std::auto_ptr<InsetBase> doClone() const = 0;
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetcommand.C lyx-1.4-cvs/src/insets/insetcommand.C
--- lyx-1.4-clean/src/insets/insetcommand.C	2005-04-23 10:15:05.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insetcommand.C	2005-05-08 10:47:07.000000000 +0200
@@ -109,12 +109,10 @@ void InsetCommand::doDispatch(LCursor & 
 	case LFUN_INSET_MODIFY: {
 		InsetCommandParams p;
 		InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
-		if (p.getCmdName().empty()) {
-			cur.undispatched();
-		} else {
+		if (p.getCmdName().empty())
+			cur.noUpdate();
+		else
 			setParams(p);
-			cur.bv().update();
-		}
 		break;
 	}
 
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetfloat.C lyx-1.4-cvs/src/insets/insetfloat.C
--- lyx-1.4-clean/src/insets/insetfloat.C	2005-04-23 10:15:08.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insetfloat.C	2005-05-08 10:44:43.000000000 +0200
@@ -160,7 +160,6 @@ void InsetFloat::doDispatch(LCursor & cu
 		params_.sideways  = params.sideways;
 		wide(params_.wide, cur.buffer().params());
 		sideways(params_.sideways, cur.buffer().params());
-		cur.bv().update();
 		break;
 	}
 
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetgraphics.C lyx-1.4-cvs/src/insets/insetgraphics.C
--- lyx-1.4-clean/src/insets/insetgraphics.C	2005-04-23 10:15:08.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insetgraphics.C	2005-05-08 10:43:21.000000000 +0200
@@ -197,10 +206,10 @@ void InsetGraphics::doDispatch(LCursor &
 		Buffer const & buffer = cur.buffer();
 		InsetGraphicsParams p;
 		InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
-		if (!p.filename.empty()) {
+		if (!p.filename.empty())
 			setParams(p);
-			cur.bv().update();
-		}
+		else
+			cur.noUpdate();
 		break;
 	}
 
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetinclude.C lyx-1.4-cvs/src/insets/insetinclude.C
--- lyx-1.4-clean/src/insets/insetinclude.C	2005-04-23 10:15:17.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insetinclude.C	2005-05-08 10:43:57.000000000 +0200
@@ -128,10 +153,10 @@ void InsetInclude::doDispatch(LCursor & 
 	case LFUN_INSET_MODIFY: {
 		InsetCommandParams p;
 		InsetIncludeMailer::string2params(cmd.argument, p);
-		if (!p.getCmdName().empty()) {
+		if (!p.getCmdName().empty())
 			set(p, cur.buffer());
-			cur.bv().update();
-		}
+		else
+			cur.noUpdate();
 		break;
 	}
 
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetnote.C lyx-1.4-cvs/src/insets/insetnote.C
--- lyx-1.4-clean/src/insets/insetnote.C	2005-04-23 10:15:17.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insetnote.C	2005-05-08 10:45:43.000000000 +0200
@@ -192,7 +192,6 @@ void InsetNote::doDispatch(LCursor & cur
 	case LFUN_INSET_MODIFY:
 		InsetNoteMailer::string2params(cmd.argument, params_);
 		setButtonLabel();
-		cur.bv().update();
 		break;
 
 	case LFUN_INSET_DIALOG_UPDATE:
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetwrap.C lyx-1.4-cvs/src/insets/insetwrap.C
--- lyx-1.4-clean/src/insets/insetwrap.C	2005-04-23 10:15:17.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insetwrap.C	2005-05-08 10:45:51.000000000 +0200
@@ -83,7 +83,6 @@ void InsetWrap::doDispatch(LCursor & cur
 		InsetWrapMailer::string2params(cmd.argument, params);
 		params_.placement = params.placement;
 		params_.width     = params.width;
-		cur.bv().update();
 		break;
 	}
 
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/updatableinset.C lyx-1.4-cvs/src/insets/updatableinset.C
--- lyx-1.4-clean/src/insets/updatableinset.C	2005-02-01 20:16:20.000000000 +0100
+++ lyx-1.4-cvs/src/insets/updatableinset.C	2005-05-08 10:44:22.000000000 +0200
@@ -99,8 +99,8 @@ void UpdatableInset::doDispatch(LCursor 
 				scroll(cur.bv(), static_cast<float>(convert<double>(cmd.argument)));
 			else
 				scroll(cur.bv(), convert<int>(cmd.argument));
-			cur.bv().update();
-		}
+		} else
+			cur.noUpdate();
 		break;
 
 	default:

Reply via email to