Am Dienstag, 22. Februar 2005 19:47 schrieb Lars Gullik Bjønnes:
> Georg Baum <[EMAIL PROTECTED]> writes:
> | I guess the assert in InsetBase::clone() should prevent sclicing? Does 
this
> | assert mean that all insets should have a doClone method?
> 
> Only all that can be instantiated.
> 
> One option os to make doClone pure-virtual in InsetBase. Then that
> will be enforced.

It is pure-virtual in InsetBase already. But not all insets inherit 
directly from InsetBase ;-)

I am going to apply the attached patch tomorrow if nobody objects.

> Description of bug and patch on list is fine.

Ok, I'll do that.

> Although it is nice to have the bugs in bugzilla as well, especially
> if the bug is not fixed right away upon discovery.

Agreed.


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-02-22 20:44:45.000000000 +0100
+++ lyx-1.4-cvs/src/insets/ChangeLog	2005-02-22 21:47:33.000000000 +0100
@@ -1,3 +1,7 @@
+2005-02-22  Georg Baum  <[EMAIL PROTECTED]>
+
+	* insetcaption.[Ch] (doClone): implement
+
 2005-02-22  Georg Baum  <[EMAIL PROTECTED]>
 
 	* insetgraphics.C (prepareFile): handle non-existing files
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetcaption.C lyx-1.4-cvs/src/insets/insetcaption.C
--- lyx-1.4-clean/src/insets/insetcaption.C	2004-11-26 14:52:41.000000000 +0100
+++ lyx-1.4-cvs/src/insets/insetcaption.C	2005-02-22 21:24:37.000000000 +0100
@@ -138,7 +138,7 @@ int InsetCaption::latex(Buffer const & b
 int InsetCaption::plaintext(Buffer const & /*buf*/,ostream & /*os*/,
 			OutputParams const & /*runparams*/) const
 {
-	// FIX: Implement me!
+	// FIXME: Implement me!
 	return 0;
 }
 
@@ -152,3 +152,9 @@ int InsetCaption::docbook(Buffer const &
 	os << "</title>\n";
 	return ret;
 }
+
+
+auto_ptr<InsetBase> InsetCaption::doClone() const
+{
+	return auto_ptr<InsetBase>(new InsetListing(*this));
+}
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetcaption.h lyx-1.4-cvs/src/insets/insetcaption.h
--- lyx-1.4-clean/src/insets/insetcaption.h	2004-11-26 14:52:41.000000000 +0100
+++ lyx-1.4-cvs/src/insets/insetcaption.h	2005-02-22 21:23:51.000000000 +0100
@@ -42,6 +42,9 @@ public:
 	///
 	int docbook(Buffer const & buf, std::ostream & os,
 		    OutputParams const & runparams) const;
+private:
+	///
+	virtual std::auto_ptr<InsetBase> doClone() const;
 };
 
 
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/ChangeLog lyx-1.4-cvs/src/mathed/ChangeLog
--- lyx-1.4-clean/src/mathed/ChangeLog	2005-02-15 18:35:30.000000000 +0100
+++ lyx-1.4-cvs/src/mathed/ChangeLog	2005-02-22 21:20:37.000000000 +0100
@@ -1,3 +1,9 @@
+2005-02-22  Georg Baum  <[EMAIL PROTECTED]>
+
+	* math_parinset.[Ch] (doClone): Implement, avoids triggering the
+	assert in InsetBase::clone()
+	* ref_inset.[Ch] (clone): rename to doClone
+
 2005-02-14  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* math_rootinset.C (idxUpDown): Silence an MSVC compiler warning
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/math_parinset.C lyx-1.4-cvs/src/mathed/math_parinset.C
--- lyx-1.4-clean/src/mathed/math_parinset.C	2003-09-07 23:25:36.000000000 +0200
+++ lyx-1.4-cvs/src/mathed/math_parinset.C	2005-02-21 22:06:20.000000000 +0100
@@ -16,6 +16,9 @@
 #include "support/std_ostream.h"
 
 
+using std::auto_ptr;
+
+
 MathParInset::MathParInset(MathArray const & ar)
 {
 	cells_[0] = ar;
@@ -48,3 +51,9 @@ void MathParInset::infoize(std::ostream 
 {
 	os << "Type: Paragraph ";
 }
+
+
+auto_ptr<InsetBase> MathParInset::doClone() const
+{
+	return auto_ptr<InsetBase>(new MathParInset(*this));
+}
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/math_parinset.h lyx-1.4-cvs/src/mathed/math_parinset.h
--- lyx-1.4-clean/src/mathed/math_parinset.h	2003-08-19 15:00:55.000000000 +0200
+++ lyx-1.4-cvs/src/mathed/math_parinset.h	2005-02-21 22:05:13.000000000 +0100
@@ -31,6 +31,9 @@ public:
 	void infoize(std::ostream & os) const;
 	///
 	void write(WriteStream & os) const;
+private:
+	///
+	virtual std::auto_ptr<InsetBase> doClone() const;
 };
 
 #endif
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/ref_inset.C lyx-1.4-cvs/src/mathed/ref_inset.C
--- lyx-1.4-clean/src/mathed/ref_inset.C	2004-11-25 19:37:59.000000000 +0100
+++ lyx-1.4-cvs/src/mathed/ref_inset.C	2005-02-22 21:15:36.000000000 +0100
@@ -44,7 +44,7 @@ RefInset::RefInset(string const & data)
 {}
 
 
-auto_ptr<InsetBase> RefInset::clone() const
+auto_ptr<InsetBase> RefInset::doClone() const
 {
 	return auto_ptr<InsetBase>(new RefInset(*this));
 }
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/ref_inset.h lyx-1.4-cvs/src/mathed/ref_inset.h
--- lyx-1.4-clean/src/mathed/ref_inset.h	2004-11-25 19:37:59.000000000 +0100
+++ lyx-1.4-cvs/src/mathed/ref_inset.h	2005-02-22 21:15:24.000000000 +0100
@@ -24,8 +24,6 @@ public:
 	///
 	explicit RefInset(std::string const & data);
 	///
-	virtual std::auto_ptr<InsetBase> clone() const;
-	///
 	//void write(WriteStream & os) const;
 	///
 	void infoize(std::ostream & os) const;
@@ -61,6 +59,9 @@ public:
 	static std::string const & getName(int type);
 protected:
 	virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
+private:
+	///
+	virtual std::auto_ptr<InsetBase> doClone() const;
 };
 
 #endif

Reply via email to