[pooma-dev] [PATCH] Fix Engine<.., MultiPatch<..> >::makeOwnC opy()

James Crotinger jcrotinger at proximation.com
Tue Apr 22 17:43:37 UTC 2003


Hmmm. I don't have time to play with this, but something looks wrong. The
sequence

	data_m.makeOwnCopy();
	if (data_m.isShared())

the isShared() test should always return false after a call to makeOwnCopy -
that should be an invariant property of any ref-counted thing. That was
certainly my intention. 

	Jim

------------------------------------------------------------------------
James A. Crotinger                           email:     jimc at numerix.com
NumeriX, LLC                                 phone:  (505) 424-4477 x104
2960 Rodeo Park Dr. W.
Santa Fe, NM 87505
 

-----Original Message-----
From: Richard Guenther [mailto:rguenth at tat.physik.uni-tuebingen.de] 
Sent: Tuesday, April 22, 2003 9:58 AM
To: pooma-dev at pooma.codesourcery.com
Cc: Jeffrey D. Oldham
Subject: [pooma-dev] [PATCH] Fix Engine<.., MultiPatch<..> >::makeOwnCopy()

Hi!

Currently for a multipatch engine makeOwnCopy() does no good (it doesnt
copy), it seems because just calling makeOwnCopy() on the
RefCountedBlockPtr does not copy the underlying engines. I didnt figure
out why and so came up with the following fix which works for me. I have
also an updated Field/BasicTest3.cpp which now checks every engine
combination for makeOwnCopy and it now succeeds for both MultiPatch<Brick>
and MultiPatch<Remote<Brick> >.

Ok to apply?

Richard.


2003 Apr 22  Richard Guenther <richard.guenther at uni-tuebingen.de>

	* Engine/MultiPatchEngine.cpp: do makeOwnCopy() manually.

===== MultiPatchEngine.cpp 1.3 vs edited =====
--- 1.3/r2/src/Engine/MultiPatchEngine.cpp	Fri Jan 24 10:35:52 2003
+++ edited/MultiPatchEngine.cpp	Tue Apr 22 17:42:04 2003
@@ -244,8 +244,17 @@
 Engine<Dim, T, MultiPatch<LayoutTag,PatchTag> >::
 makeOwnCopy()
 {
-  data_m.makeOwnCopy();
-
+  PAssert(data_m.isValid());
+  if (data_m.isShared()) {
+    PatchContainer_t model = data_m;
+    data_m = PatchContainer_t(model.size());
+    for (int i=0; i<model.size(); ++i) {
+      data_m[i] = model[i];
+      data_m[i].makeOwnCopy();
+    }
+    pDirty_m = new bool(*pDirty_m);
+  }
+
   return *this;
 }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/pooma-dev/attachments/20030422/200652d2/attachment.html>


More information about the pooma-dev mailing list