0029355: OCCT 6.9.1 persistence restored in OCCT 7.2.0 not working
authorabv <abv@opencascade.com>
Sat, 2 Dec 2017 08:24:58 +0000 (11:24 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 8 Dec 2017 13:39:26 +0000 (16:39 +0300)
Auxiliary classes StdObjMgt_ReadData::Object and StdObjMgt_WriteData::Object are renamed to "ObjectSentry" (to better reflect their nature); constructor is made explicit to ensure that such objects are always created intentionally.
These objects are instantiated explicitly in the body of relevant functions, instead of implicit creation as temporary objects when function requires such object as argument.
Variable used to get char from stream is nullified in several places in FSD_File and other classes, to avoid possible usage of uninitialized memory in case if stream is bad.

18 files changed:
src/DDF/DDF_IOStream.cxx
src/FSD/FSD_CmpFile.cxx
src/FSD/FSD_File.cxx
src/ShapePersistent/ShapePersistent_HArray1.hxx
src/StdLPersistent/StdLPersistent_HArray1.cxx
src/StdLPersistent/StdLPersistent_HArray2.cxx
src/StdLPersistent/StdLPersistent_HString.cxx
src/StdObjMgt/StdObjMgt_ReadData.cxx
src/StdObjMgt/StdObjMgt_ReadData.hxx
src/StdObjMgt/StdObjMgt_WriteData.cxx
src/StdObjMgt/StdObjMgt_WriteData.hxx
src/StdObject/StdObject_Location.hxx
src/StdObject/StdObject_Shape.hxx
src/StdObject/StdObject_gp_Axes.hxx
src/StdObject/StdObject_gp_Trsfs.hxx
src/StdObject/StdObject_gp_Vectors.hxx
tests/bugs/fclasses/begin
tests/bugs/fclasses/bug29355 [new file with mode: 0644]

index 61d0104..d116d3d 100644 (file)
@@ -281,7 +281,7 @@ void DDF_IOStream::ReadExtendedLine(TCollection_ExtendedString& buffer)
 
 void DDF_IOStream::ReadChar(TCollection_AsciiString& buffer, const Standard_Integer rsize)
 {
-  char             c;
+  char c = '\0';
   Standard_Integer ccount = 0;
 
   buffer.Clear();
@@ -1216,7 +1216,7 @@ Storage_Error DDF_IOStream::BeginReadDataSection()
 void DDF_IOStream::ReadPersistentObjectHeader(Standard_Integer& aRef,
                                          Standard_Integer& aType) 
 {
-  char c;
+  char c = '\0';
 
   myIStream->get(c);
 
@@ -1256,7 +1256,7 @@ void DDF_IOStream::ReadPersistentObjectHeader(Standard_Integer& aRef,
 
 void DDF_IOStream::BeginReadPersistentObjectData() 
 {
-  char c;
+  char c = '\0';
   myIStream->get(c);
   while (c != '(') {
     if (IsEnd() || (c != ' ') || (c == '\n')) {
@@ -1273,7 +1273,7 @@ void DDF_IOStream::BeginReadPersistentObjectData()
 
 void DDF_IOStream::BeginReadObjectData() 
 {
-  char c;
+  char c = '\0';
   myIStream->get(c);
   while (c != '(') {
     if (IsEnd() || (c != ' ') || (c == '\n')) {
@@ -1290,7 +1290,7 @@ void DDF_IOStream::BeginReadObjectData()
 
 void DDF_IOStream::EndReadObjectData() 
 {
-  char c;
+  char c = '\0';
   myIStream->get(c);
   while (c != ')') {
     if (IsEnd() || (c != ' ') || (c == '\n')) {
@@ -1307,7 +1307,7 @@ void DDF_IOStream::EndReadObjectData()
 
 void DDF_IOStream::EndReadPersistentObjectData() 
 {
-  char c;
+  char c = '\0';
 
   myIStream->get(c);
   while (c != ')') {
index 594fe0a..e23394c 100644 (file)
@@ -325,7 +325,7 @@ void FSD_CmpFile::EndWritePersistentObjectData()
 void FSD_CmpFile::ReadPersistentObjectHeader(Standard_Integer& aRef,
                                              Standard_Integer& aType)
 {
-  char c;
+  char c = '\0';
 
   myStream.get(c);
 
@@ -388,7 +388,7 @@ void FSD_CmpFile::EndReadObjectData()
 
 void FSD_CmpFile::EndReadPersistentObjectData()
 {
-  char c;
+  char c = '\0';
 
   myStream.get(c);
   while (c != '\n' && (c != '\r')) {
index 10afce9..c02ee5c 100644 (file)
@@ -280,7 +280,7 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
 
 void FSD_File::ReadChar(TCollection_AsciiString& buffer, const Standard_Size rsize)
 {
-  char             c;
+  char c = '\0';
   Standard_Size ccount = 0;
 
   buffer.Clear();
@@ -1234,7 +1234,7 @@ Storage_Error FSD_File::BeginReadDataSection()
 void FSD_File::ReadPersistentObjectHeader(Standard_Integer& aRef,
                                          Standard_Integer& aType) 
 {
-  char c;
+  char c = '\0';
 
   myStream.get(c);
 
@@ -1277,7 +1277,7 @@ void FSD_File::ReadPersistentObjectHeader(Standard_Integer& aRef,
 
 void FSD_File::BeginReadPersistentObjectData() 
 {
-  char c;
+  char c = '\0';
   myStream.get(c);
   while (c != '(') {
     if (IsEnd() || (c != ' ') || (c == '\n')) {
@@ -1296,8 +1296,7 @@ void FSD_File::BeginReadPersistentObjectData()
 
 void FSD_File::BeginReadObjectData() 
 {
-
-  char c;
+  char c = '\0';
   myStream.get(c);
   while (c != '(') {
     if (IsEnd() || (c != ' ') || (c == '\n')) {
@@ -1316,8 +1315,7 @@ void FSD_File::BeginReadObjectData()
 
 void FSD_File::EndReadObjectData() 
 {
-
-  char c;
+  char c = '\0';
   myStream.get(c);
   while (c != ')') {
     if (IsEnd() || (c != ' ') || (c == '\n')) {
@@ -1336,8 +1334,7 @@ void FSD_File::EndReadObjectData()
 
 void FSD_File::EndReadPersistentObjectData() 
 {
-
-  char c;
+  char c = '\0';
 
   myStream.get(c);
   while (c != ')') {
index 6ddbf7c..a1a4b79 100644 (file)
@@ -49,8 +49,10 @@ public:
 };
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, Poly_Triangle& theTriangle)
+  (StdObjMgt_ReadData& theReadData, Poly_Triangle& theTriangle)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   Standard_Integer N1, N2, N3;
   theReadData >> N1 >> N2 >> N3;
   theTriangle.Set (N1, N2, N3);
@@ -58,8 +60,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const Poly_Triangle& theTriangle)
+  (StdObjMgt_WriteData& theWriteData, const Poly_Triangle& theTriangle)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   Standard_Integer N1, N2, N3;
   theTriangle.Get(N1, N2, N3);
   theWriteData << N1 << N2 << N3;
index 7318651..c262021 100644 (file)
@@ -24,13 +24,13 @@ void StdLPersistent_HArray1::base::Read (StdObjMgt_ReadData& theReadData)
   theReadData >> aLowerBound >> anUpperBound;
   createArray (aLowerBound, anUpperBound);
 
-  StdObjMgt_ReadData::Object anObjectData (theReadData);
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
 
   Standard_Integer aSize;
-  anObjectData >> aSize;
+  theReadData >> aSize;
 
   for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
-    readValue (anObjectData, i);
+    readValue (theReadData, i);
 }
 
 //=======================================================================
@@ -42,10 +42,10 @@ void StdLPersistent_HArray1::base::Write (StdObjMgt_WriteData& theWriteData) con
   Standard_Integer aLowerBound = lowerBound(), anUpperBound = upperBound();
   theWriteData << aLowerBound << anUpperBound;
 
-  StdObjMgt_WriteData::Object anObjectData(theWriteData);
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
 
   Standard_Integer aSize = anUpperBound - aLowerBound + 1;
-  anObjectData << aSize;
+  theWriteData << aSize;
 
   for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
     writeValue(theWriteData, i);
index cde9009..dffa766 100644 (file)
@@ -27,14 +27,14 @@ void StdLPersistent_HArray2::base::Read (StdObjMgt_ReadData& theReadData)
   theReadData >> aLowerRow >> aLowerCol >> anUpperRow >> anUpperCol;
   createArray (aLowerRow, aLowerCol, anUpperRow, anUpperCol);
 
-  StdObjMgt_ReadData::Object anObjectData (theReadData);
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
 
   Standard_Integer aSize;
-  anObjectData >> aSize;
+  theReadData >> aSize;
 
   for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
     for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
-      readValue (anObjectData, aRow, aCol);
+      readValue (theReadData, aRow, aCol);
 }
 
 //=======================================================================
@@ -48,12 +48,12 @@ void StdLPersistent_HArray2::base::Write (StdObjMgt_WriteData& theWriteData) con
   upperBound(anUpperRow, anUpperCol);
   theWriteData << aLowerRow << aLowerCol << anUpperRow << anUpperCol;
 
-  StdObjMgt_WriteData::Object anObjectData(theWriteData);
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
 
   Standard_Integer aSize = (anUpperRow - aLowerRow + 1) * (anUpperCol - aLowerCol + 1);
-  anObjectData << aSize;
+  theWriteData << aSize;
 
   for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
     for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
-      writeValue(anObjectData, aRow, aCol);
+      writeValue(theWriteData, aRow, aCol);
 }
index 436f1ca..a143677 100644 (file)
@@ -26,16 +26,16 @@ template <class StringClass, typename CharType>
 void StdLPersistent_HString::instance<StringClass, CharType>::Read
   (StdObjMgt_ReadData& theReadData)
 {
-  StdObjMgt_ReadData::Object anObjectData (theReadData);
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
 
   Standard_Integer aSize;
-  anObjectData >> aSize;
+  theReadData >> aSize;
   myValue = new StringClass (aSize, 0);
 
   for (Standard_Integer i = 1; i <= aSize; i++)
   {
     CharType aChar;
-    anObjectData >> aChar;
+    theReadData >> aChar;
     myValue->SetValue (i, aChar);
   }
 }
@@ -48,15 +48,15 @@ template <class StringClass, typename CharType>
 void StdLPersistent_HString::instance<StringClass, CharType>::Write
   (StdObjMgt_WriteData& theWriteData) const
 {
-  StdObjMgt_WriteData::Object anObjectData(theWriteData);
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
 
   Standard_Integer aSize = myValue->Length();
-  anObjectData << aSize;
+  theWriteData << aSize;
 
   for (Standard_Integer i = 1; i <= aSize; i++)
   {
     CharType aChar (0);
-    anObjectData << aChar;
+    theWriteData << aChar;
   }
 }
 
index 9bb9214..5d80270 100644 (file)
@@ -47,8 +47,10 @@ Handle(StdObjMgt_Persistent) StdObjMgt_ReadData::ReadReference()
 //purpose  : Read persistent data from a file
 //=======================================================================
 StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID)
+  (StdObjMgt_ReadData& theReadData, Standard_GUID& theGUID)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   Standard_Integer      a32b;
   Standard_ExtCharacter a16b[3];
   Standard_Character    a8b [6];
index 8582e14..f81d379 100644 (file)
@@ -26,7 +26,24 @@ class Standard_GUID;
 class StdObjMgt_ReadData
 {
 public:
-  class Object;
+  //! Auxiliary class used to automate begin and end of
+  //! reading object (eating opening and closing parenthesis)
+  //! at constructor and destructor
+  class ObjectSentry
+  {
+  public:
+    explicit ObjectSentry (StdObjMgt_ReadData& theData) : myReadData (&theData)
+    { myReadData->myDriver->BeginReadObjectData(); }
+
+    ~ObjectSentry ()
+    { myReadData->myDriver->EndReadObjectData(); }
+
+  private:
+    StdObjMgt_ReadData* myReadData;
+
+    ObjectSentry (const ObjectSentry&);
+    ObjectSentry& operator = (const ObjectSentry&);
+  };
 
   Standard_EXPORT StdObjMgt_ReadData
     (Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects);
@@ -88,31 +105,7 @@ private:
   NCollection_Array1<Handle(StdObjMgt_Persistent)> myPersistentObjects;
 };
 
-class StdObjMgt_ReadData::Object
-{
-public:
-  Object (StdObjMgt_ReadData& theData) : myReadData (&theData)
-    { myReadData->myDriver->BeginReadObjectData(); }
-  Object(const StdObjMgt_ReadData::Object& theOther) : myReadData(theOther.myReadData)
-    { myReadData->myDriver->BeginReadObjectData(); }
-
-  ~Object()
-    { myReadData->myDriver->EndReadObjectData(); }
-
-  operator StdObjMgt_ReadData&()
-    { return *myReadData; }
-
-  template <class Data>
-  StdObjMgt_ReadData& operator >> (Data& theData)
-    { return *myReadData >> theData; }
-
-private:
-  StdObjMgt_ReadData* myReadData;
-
-  StdObjMgt_ReadData::Object& operator = (const StdObjMgt_ReadData::Object&);
-};
-
 Standard_EXPORT StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID);
+  (StdObjMgt_ReadData& theReadData, Standard_GUID& theGUID);
 
 #endif // _StdObjMgt_ReadData_HeaderFile
index cbd9b4f..7830181 100644 (file)
@@ -44,8 +44,10 @@ StdObjMgt_WriteData& StdObjMgt_WriteData::operator << (const Handle(StdObjMgt_Pe
 //purpose  : Read persistent data from a file
 //=======================================================================
 StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const Standard_GUID& theGUID)
+  (StdObjMgt_WriteData& theWriteData, const Standard_GUID& theGUID)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const Standard_UUID anUUID = theGUID.ToUUID();
 
   Standard_Integer      a32b;
index 48d5ea4..22b97c9 100644 (file)
@@ -25,7 +25,24 @@ class StdObjMgt_WriteData
 {
 public:
 
-  class Object;
+  //! Auxiliary class used to automate begin and end of
+  //! writing object (adding opening and closing parenthesis)
+  //! at constructor and destructor
+  class ObjectSentry
+  {
+  public:
+    explicit ObjectSentry (StdObjMgt_WriteData& theData) : myWriteData(&theData)
+    { myWriteData->myDriver->BeginWriteObjectData(); }
+
+    ~ObjectSentry()
+    { myWriteData->myDriver->EndWriteObjectData(); }
+
+  private:
+    StdObjMgt_WriteData* myWriteData;
+
+    ObjectSentry (const ObjectSentry&);
+    ObjectSentry& operator = (const ObjectSentry&);
+  };
 
   Standard_EXPORT StdObjMgt_WriteData 
     (Storage_BaseDriver& theDriver);
@@ -71,31 +88,7 @@ private:
   Storage_BaseDriver* myDriver;
 };
 
-class StdObjMgt_WriteData::Object
-{
-public:
-  Object (StdObjMgt_WriteData& theData) : myWriteData(&theData)
-    { myWriteData->myDriver->BeginWriteObjectData(); }
-  Object (const StdObjMgt_WriteData::Object& theOther) : myWriteData(theOther.myWriteData)
-    { myWriteData->myDriver->BeginWriteObjectData(); }
-
-  ~Object()
-    { myWriteData->myDriver->EndWriteObjectData(); }
-
-  operator StdObjMgt_WriteData& ()
-    { return *myWriteData; }
-
-  template <class Data>
-  StdObjMgt_WriteData& operator << (Data& theData)
-    { return *myWriteData << theData; }
-
-private:
-  StdObjMgt_WriteData* myWriteData;
-
-  StdObjMgt_WriteData::Object& operator = (const StdObjMgt_WriteData::Object&);
-};
-
 Standard_EXPORT StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const Standard_GUID& theGUID);
+  (StdObjMgt_WriteData& theWriteData, const Standard_GUID& theGUID);
 
 #endif // _StdObjMgt_WriteData_HeaderFile
index 29a0854..7c729d4 100644 (file)
@@ -40,22 +40,24 @@ private:
   Handle(StdObjMgt_Persistent) myData;
 
   friend StdObjMgt_ReadData& operator >>
-    (StdObjMgt_ReadData::Object, StdObject_Location&);
+    (StdObjMgt_ReadData&, StdObject_Location&);
   friend StdObjMgt_WriteData& operator <<
-    (StdObjMgt_WriteData::Object, const StdObject_Location&);
+    (StdObjMgt_WriteData&, const StdObject_Location&);
 };
 
 //! Read persistent data from a file.
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, StdObject_Location& theLocation)
+  (StdObjMgt_ReadData& theReadData, StdObject_Location& theLocation)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   return theReadData >> theLocation.myData;
 }
 
 //! Write persistent data to a file.
 inline StdObjMgt_WriteData& operator <<
-(StdObjMgt_WriteData::Object theWriteData, const StdObject_Location& theLocation)
+  (StdObjMgt_WriteData& theWriteData, const StdObject_Location& theLocation)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
   return theWriteData << theLocation.myData;
 }
 
index 58d0111..7d1ab80 100644 (file)
@@ -48,23 +48,25 @@ protected:
   Standard_Integer                     myOrient;
 
   friend StdObjMgt_ReadData& operator >>
-    (StdObjMgt_ReadData::Object, StdObject_Shape&);
+    (StdObjMgt_ReadData&, StdObject_Shape&);
   friend StdObjMgt_WriteData& operator <<
-    (StdObjMgt_WriteData::Object, const StdObject_Shape&);
+    (StdObjMgt_WriteData&, const StdObject_Shape&);
 };
 
 //! Read persistent data from a file.
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, StdObject_Shape& theShape)
+  (StdObjMgt_ReadData& theReadData, StdObject_Shape& theShape)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   theShape.read (theReadData);
   return theReadData;
 }
 
 //! Write persistent data to a file.
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const StdObject_Shape& theShape)
+  (StdObjMgt_WriteData& theWriteData, const StdObject_Shape& theShape)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
   theShape.write (theWriteData);
   return theWriteData;
 }
index f5c78bc..105487e 100644 (file)
@@ -26,8 +26,9 @@
 
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Ax2d& theAx)
+  (StdObjMgt_ReadData& theReadData, gp_Ax2d& theAx)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   gp_Pnt2d aLoc;
   gp_Dir2d aDir;
   theReadData >> aLoc >> aDir;
@@ -36,8 +37,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& 
-  write (StdObjMgt_WriteData::Object theWriteData, const gp_Ax2d& theAx)
+  write (StdObjMgt_WriteData& theWriteData, const gp_Ax2d& theAx)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const gp_Pnt2d& aLoc = theAx.Location();
   const gp_Dir2d& aDir = theAx.Direction();
   theWriteData << aLoc << aDir;
@@ -45,8 +48,10 @@ inline StdObjMgt_WriteData&
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Ax2d& theAx)
+  (StdObjMgt_WriteData& theWriteData, const gp_Ax2d& theAx)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const gp_Pnt2d& aLoc = theAx.Location();
   const gp_Dir2d& aDir = theAx.Direction();
   theWriteData << aLoc << aDir;
@@ -54,8 +59,9 @@ inline StdObjMgt_WriteData& operator <<
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Ax22d& theAx)
+  (StdObjMgt_ReadData& theReadData, gp_Ax22d& theAx)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   gp_Pnt2d aLoc;
   gp_Dir2d aYDir, aXDir;
   theReadData >> aLoc >> aYDir >> aXDir;
@@ -64,8 +70,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Ax22d& theAx)
+  (StdObjMgt_WriteData& theWriteData, const gp_Ax22d& theAx)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const gp_Pnt2d& aLoc = theAx.Location();
   const gp_Dir2d& aYDir = theAx.YDirection();
   const gp_Dir2d& aXDir = theAx.XDirection();
@@ -74,8 +82,9 @@ inline StdObjMgt_WriteData& operator <<
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Ax1& theAx)
+  (StdObjMgt_ReadData& theReadData, gp_Ax1& theAx)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   gp_Pnt aLoc;
   gp_Dir aDir;
   theReadData >> aLoc >> aDir;
@@ -84,8 +93,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData&
-  write(StdObjMgt_WriteData::Object theWriteData, const gp_Ax1& theAx)
+  write(StdObjMgt_WriteData& theWriteData, const gp_Ax1& theAx)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const gp_Pnt& aLoc = theAx.Location();
   const gp_Dir& aDir = theAx.Direction();
   theWriteData << aLoc << aDir;
@@ -93,8 +104,10 @@ inline StdObjMgt_WriteData&
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Ax1& theAx)
+  (StdObjMgt_WriteData& theWriteData, const gp_Ax1& theAx)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const gp_Pnt& aLoc = theAx.Location();
   const gp_Dir& aDir = theAx.Direction();
   theWriteData << aLoc << aDir;
@@ -102,8 +115,9 @@ inline StdObjMgt_WriteData& operator <<
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Ax2& theAx)
+  (StdObjMgt_ReadData& theReadData, gp_Ax2& theAx)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   gp_Ax1 anAx;
   gp_Dir aYDir, aXDir;
   theReadData >> anAx >> aYDir >> aXDir;
@@ -112,8 +126,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Ax2& theAx)
+  (StdObjMgt_WriteData& theWriteData, const gp_Ax2& theAx)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const gp_Ax1& anAx = theAx.Axis();
   const gp_Dir& aYDir = theAx.YDirection();
   const gp_Dir& aXDir = theAx.XDirection();
@@ -122,8 +138,9 @@ inline StdObjMgt_WriteData& operator <<
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Ax3& theAx)
+  (StdObjMgt_ReadData& theReadData, gp_Ax3& theAx)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   gp_Ax1 anAx;
   gp_Dir aYDir, aXDir;
   theReadData >> anAx >> aYDir >> aXDir;
@@ -134,8 +151,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-(StdObjMgt_WriteData::Object theWriteData, const gp_Ax3& theAx)
+  (StdObjMgt_WriteData& theWriteData, const gp_Ax3& theAx)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   const gp_Ax1& anAx = theAx.Axis();
   const gp_Dir& aYDir = theAx.YDirection();
   const gp_Dir& aXDir = theAx.XDirection();
index 54cc6a2..8d5d311 100644 (file)
@@ -25,8 +25,9 @@
 
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Mat2d& theMat)
+  (StdObjMgt_ReadData& theReadData, gp_Mat2d& theMat)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   theReadData
     >> theMat(1, 1) >> theMat(1, 2)
     >> theMat(2, 1) >> theMat(2, 2);
@@ -34,8 +35,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Mat2d& theMat)
+  (StdObjMgt_WriteData& theWriteData, const gp_Mat2d& theMat)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData
     << theMat(1, 1) << theMat(1, 2)
     << theMat(2, 1) << theMat(2, 2);
@@ -43,8 +46,9 @@ inline StdObjMgt_WriteData& operator <<
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Mat& theMat)
+  (StdObjMgt_ReadData& theReadData, gp_Mat& theMat)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
   theReadData
     >> theMat(1, 1) >> theMat(1, 2) >> theMat(1, 3)
     >> theMat(2, 1) >> theMat(2, 2) >> theMat(2, 3)
@@ -53,8 +57,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Mat& theMat)
+  (StdObjMgt_WriteData& theWriteData, const gp_Mat& theMat)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData
     << theMat(1, 1) << theMat(1, 2) << theMat(1, 3)
     << theMat(2, 1) << theMat(2, 2) << theMat(2, 3)
@@ -63,8 +69,10 @@ inline StdObjMgt_WriteData& operator <<
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Trsf2d& theTrsf)
+  (StdObjMgt_ReadData& theReadData, gp_Trsf2d& theTrsf)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   Standard_Real    aScale;
   Standard_Integer aForm;
   gp_Mat2d         aMat;
@@ -79,8 +87,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-(StdObjMgt_WriteData::Object theWriteData, const gp_Trsf2d& theTrsf)
+  (StdObjMgt_WriteData& theWriteData, const gp_Trsf2d& theTrsf)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   Standard_Real    aScale = theTrsf.ScaleFactor();
   Standard_Integer aForm  = theTrsf.Form();
   const gp_Mat2d&  aMat   = theTrsf.HVectorialPart();
@@ -92,8 +102,10 @@ inline StdObjMgt_WriteData& operator <<
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Trsf& theTrsf)
+  (StdObjMgt_ReadData& theReadData, gp_Trsf& theTrsf)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   Standard_Real    aScale;
   Standard_Integer aForm;
   gp_Mat           aMat;
@@ -110,8 +122,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Trsf& theTrsf)
+  (StdObjMgt_WriteData& theWriteData, const gp_Trsf& theTrsf)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   Standard_Real    aScale = theTrsf.ScaleFactor();
   Standard_Integer aForm  = theTrsf.Form();
   const gp_Mat&    aMat   = theTrsf.HVectorialPart();
index 4090a25..66b28f0 100644 (file)
 
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_XY& theXY)
+  (StdObjMgt_ReadData& theReadData, gp_XY& theXY)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   Standard_Real aX, aY;
   theReadData >> aX >> aY;
   theXY.SetCoord (aX, aY);
@@ -37,16 +39,20 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_XY& theXY)
+  (StdObjMgt_WriteData& theWriteData, const gp_XY& theXY)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   Standard_Real aX = theXY.X(), aY = theXY.Y();
   theWriteData << aX << aY;
   return theWriteData;
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Pnt2d& thePnt)
+  (StdObjMgt_ReadData& theReadData, gp_Pnt2d& thePnt)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   gp_XY aXY;
   theReadData >> aXY;
   thePnt.SetXY (aXY);
@@ -54,15 +60,19 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Pnt2d& thePnt)
+  (StdObjMgt_WriteData& theWriteData, const gp_Pnt2d& thePnt)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData << thePnt.XY();
   return theWriteData;
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Vec2d& theVec)
+  (StdObjMgt_ReadData& theReadData, gp_Vec2d& theVec)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   gp_XY aXY;
   theReadData >> aXY;
   theVec.SetXY (aXY);
@@ -70,15 +80,19 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Vec2d& theVec)
+  (StdObjMgt_WriteData& theWriteData, const gp_Vec2d& theVec)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData << theVec.XY();
   return theWriteData;
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Dir2d& theDir)
+  (StdObjMgt_ReadData& theReadData, gp_Dir2d& theDir)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   gp_XY aXY;
   theReadData >> aXY;
   theDir.SetXY (aXY);
@@ -86,15 +100,19 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Dir2d& theDir)
+  (StdObjMgt_WriteData& theWriteData, const gp_Dir2d& theDir)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData << theDir.XY();
   return theWriteData;
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_XYZ& theXYZ)
+  (StdObjMgt_ReadData& theReadData, gp_XYZ& theXYZ)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   Standard_Real aX, aY, aZ;
   theReadData >> aX >> aY >> aZ;
   theXYZ.SetCoord(aX, aY, aZ);
@@ -102,16 +120,20 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_XYZ& theXYZ)
+  (StdObjMgt_WriteData& theWriteData, const gp_XYZ& theXYZ)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   Standard_Real aX = theXYZ.X(), aY = theXYZ.Y(), aZ = theXYZ.Z();
   theWriteData << aX << aY << aZ;
   return theWriteData;
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Pnt& thePnt)
+  (StdObjMgt_ReadData& theReadData, gp_Pnt& thePnt)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   gp_XYZ aXYZ;
   theReadData >> aXYZ;
   thePnt.SetXYZ (aXYZ);
@@ -119,15 +141,19 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Pnt& thePnt)
+  (StdObjMgt_WriteData& theWriteData, const gp_Pnt& thePnt)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData << thePnt.XYZ();
   return theWriteData;
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Vec& theVec)
+  (StdObjMgt_ReadData& theReadData, gp_Vec& theVec)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   gp_XYZ aXYZ;
   theReadData >> aXYZ;
   theVec.SetXYZ (aXYZ);
@@ -135,15 +161,19 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Vec& theVec)
+  (StdObjMgt_WriteData& theWriteData, const gp_Vec& theVec)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData << theVec.XYZ();
   return theWriteData;
 }
 
 inline StdObjMgt_ReadData& operator >>
-  (StdObjMgt_ReadData::Object theReadData, gp_Dir& theDir)
+  (StdObjMgt_ReadData& theReadData, gp_Dir& theDir)
 {
+  StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
+
   gp_XYZ aXYZ;
   theReadData >> aXYZ;
   theDir.SetXYZ(aXYZ);
@@ -151,8 +181,10 @@ inline StdObjMgt_ReadData& operator >>
 }
 
 inline StdObjMgt_WriteData& operator <<
-  (StdObjMgt_WriteData::Object theWriteData, const gp_Dir& theDir)
+  (StdObjMgt_WriteData& theWriteData, const gp_Dir& theDir)
 {
+  StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
+
   theWriteData << theDir.XYZ();
   return theWriteData;
 }
index 5fee6fb..6b038e8 100755 (executable)
@@ -1,9 +1 @@
 set subgroup fclasses
-
-
-
-
-
-
-
-
diff --git a/tests/bugs/fclasses/bug29355 b/tests/bugs/fclasses/bug29355
new file mode 100644 (file)
index 0000000..88b5a80
--- /dev/null
@@ -0,0 +1,16 @@
+puts "# ======================================================================"
+puts "# 0029355: OCCT 6.9.1 persistence restored in OCCT 7.2.0 not working"
+puts "# ======================================================================"
+
+pload OCAF MODELING
+
+puts ""
+puts "# Check reading of shape from FSD archive"
+fsdread [locate_data_file bug29355.fsd] a
+checkshape a
+checknbshapes a -face 14 -solid 0 -edge 39 -vertex 26
+
+puts ""
+puts "# Check that reading fails with expected message on truncated file"
+puts "REQUIRED 29355 ALL: Error : 6"
+catch {fsdread [locate_data_file bug29355_truncated.fsd] a}