]> OCCT Git - occt.git/commitdiff
0031785: [REGRESSION] Application Framework - application crashes on reading XBF...
authorabv <abv@opencascade.com>
Tue, 22 Sep 2020 12:24:54 +0000 (15:24 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 28 Sep 2020 07:46:01 +0000 (10:46 +0300)
Class CDF_Session is removed.

Integrated previously but not described:

0029195: OCAF - ensure thread safety for different documents.

Static local variables are eliminated in PCDM package.
Global documents metadata look-up table and directory of opened documents are removed.
Look-up table is maintained now as field in instances of the CDM_Application class.
Methods providing iteration by components are removed from class CDF_Store; signature of methods returned Standard_ExtString is changed to return Handle(TCollection_HExtendedString).
Support of different "Presentations" of documents is eliminated.

33 files changed:
dox/dev_guides/upgrade/upgrade.md
samples/ocafsamples/TDocStd_Sample.cxx
src/CDF/CDF_Application.cxx
src/CDF/CDF_Application.hxx
src/CDF/CDF_DirectoryIterator.cxx
src/CDF/CDF_FWOSDriver.cxx
src/CDF/CDF_FWOSDriver.hxx
src/CDF/CDF_MetaDataDriver.cxx
src/CDF/CDF_MetaDataDriver.hxx
src/CDF/CDF_Session.cxx [deleted file]
src/CDF/CDF_Session.hxx [deleted file]
src/CDF/CDF_Store.cxx
src/CDF/CDF_StoreList.cxx
src/CDF/FILES
src/CDM/CDM_Application.cxx
src/CDM/CDM_Application.hxx
src/CDM/CDM_ApplicationDirectory.hxx [deleted file]
src/CDM/CDM_Document.cxx
src/CDM/CDM_MetaData.cxx
src/CDM/CDM_MetaData.hxx
src/CDM/FILES
src/DDocStd/DDocStd.cxx
src/PCDM/PCDM_ReferenceIterator.cxx
src/PCDM/PCDM_ReferenceIterator.hxx
src/QABugs/QABugs_20.cxx
src/TDocStd/TDocStd_Application.cxx
src/TDocStd/TDocStd_Application.hxx
src/TKQADraw/EXTERNLIB
src/TObj/TObj_Application.cxx
src/XmlLDrivers/XmlLDrivers_DocumentRetrievalDriver.cxx
tests/bugs/caf/bug31785 [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Communicator.cxx
tools/DFBrowser/DFBrowser_Window.cxx

index 89d7d509bfcf0c7288d7e8ea13fd72688805cb87..f1824c5bc65aeb88ee37031a904f1ad7cfa2c81a 100644 (file)
@@ -2120,6 +2120,26 @@ Old three Message_Printer::Send() methods remain defined virtual with unused las
 
 Redundant class Prs3d_Root has been marked as deprecated - Prs3d_Presentation::NewGroup() should be called directly.
 
+@subsection upgrade_750_cdf_session Support of multiple OCAF application instances
+
+Class *CDF_Session* has been removed.
+That class was used to store global instance of OCAF application (object of class *CDM_Application* or descendant, typically *TDataStd_Application*).
+Global directory of all opened OCAF documents has been removed as well; such directory is maintained now by each instance of the *CDM_Application* class.
+
+This allows creating programs that work with different OCAF documents concurrently in paralel threads,
+provided that each thread deals with its own instance of *TDataStd_Application* and documents managed by this instance.
+
+Note that neither *TDataStd_Application* nor *TDocStd_Document* is protected from concurrent access from several threads.
+Such protection, if necessary, shall be implemented on the application level.
+For an example, access to labels and attributes could be protected by mutex if there is a probability that different threads access the same labels / attributes:
+~~~~~
+  {
+    Standard_Mutex::Sentry aSentry (myMainLabelAccess);
+    TDF_Label aChildLab = aDocument->Main().NewChild();
+    TDataStd_Integer::Set(aChildLab, 0);
+  }
+~~~~~
+
 @subsection upgrade_750_draw_hotkeys Draw Harness hotkeys
 
 Draw Harness hotkeys **W** (Wireframe) and **S** (Shaded) have been re-mapped to **Ctrl+W** and **Ctrl+S**.
index e028fef03658eb755e42f61dc09e4b3e66d0404b..6514a08b12736b2c5c4cb2ab35c640619b375a34 100644 (file)
@@ -19,7 +19,6 @@
 #include <TDocStd_Application.hxx>
 #include <TDocStd_Document.hxx>
 #include <TDocStd_XLinkTool.hxx> 
-#include <CDF_Session.hxx> 
 
 // ====================================================================================
 // This sample contains template for typical actions with OCAF document at application 
@@ -33,23 +32,7 @@ static void Sample()
   
   //...Creating application 
 
-  Handle(TDocStd_Application) app; 
-
-  // the application is now handled by the CDF_Session variable
-
-
-  //...Retrieving the  application
-
-
-  if (!CDF_Session::Exists()) {
-    Handle(CDF_Session) S = CDF_Session::CurrentSession();  
-    if (!S->HasCurrentApplication())  
-    Standard_DomainError::Raise("DDocStd::Find no applicative session");
-    app = Handle(TDocStd_Application)::DownCast(S->CurrentApplication());
-  }
-  else {
-    // none active application
-  }
+  Handle(TDocStd_Application) app = new TDocStd_Application;
   
   //...Creating the new document (document conatins a framework) 
 
index 2de42679768d0598f94854a71d5cbf8cdb72c6b8..a1c16d87e68f89c669bc9b8169f4af2833c93769 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <CDF_Application.hxx>
 #include <CDF_Directory.hxx>
-#include <CDF_Session.hxx>
 #include <CDF_FWOSDriver.hxx>
 #include <CDM_CanCloseStatus.hxx>
 #include <CDM_Document.hxx>
@@ -42,7 +41,7 @@ IMPLEMENT_STANDARD_RTTIEXT(CDF_Application,CDM_Application)
 CDF_Application::CDF_Application():myRetrievableStatus(PCDM_RS_OK) 
 {
   myDirectory      = new CDF_Directory();
-  myMetaDataDriver = new CDF_FWOSDriver;
+  myMetaDataDriver = new CDF_FWOSDriver (MetaDataLookUpTable());
 }
 
 //=======================================================================
@@ -270,7 +269,7 @@ Handle(CDM_Document) CDF_Application::Retrieve (const Handle(CDM_MetaData)& aMet
     SetReferenceCounter(theDocument,PCDM_RetrievalDriver::ReferenceCounter(aMetaData->FileName(), MessageDriver()));
     
     SetDocumentVersion(theDocument,aMetaData);
-    myMetaDataDriver->ReferenceIterator()->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration);
+    myMetaDataDriver->ReferenceIterator(MessageDriver())->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration);
 
     try {    
       OCC_CATCH_SIGNALS
@@ -284,7 +283,8 @@ Handle(CDM_Document) CDF_Application::Retrieve (const Handle(CDM_MetaData)& aMet
        throw Standard_Failure(aMsg.str().c_str());
       }        
     }
-    myRetrievableStatus = theReader->GetStatus();    
+    myRetrievableStatus = theReader->GetStatus();
+    theDocument->Open (this); // must be done before SetMetaData
     theDocument->SetMetaData(aMetaData);
 
     theDocumentToReturn=theDocument;
index f7971a15118335d287c003b792285b2e29e63675..3a979fb4f9c556d41f1aaceac7124d330fbeba73 100644 (file)
@@ -28,7 +28,6 @@
 #include <NCollection_IndexedDataMap.hxx>
 
 class Standard_NoSuchObject;
-class CDF_Session;
 class Standard_GUID;
 class CDM_Document;
 class TCollection_ExtendedString;
@@ -172,9 +171,6 @@ public:
   //! returns MetaDatdDriver of this application
   Standard_EXPORT Handle(CDF_MetaDataDriver) MetaDataDriver() const;
 
-friend class CDF_Session;
-
-
   DEFINE_STANDARD_RTTIEXT(CDF_Application,CDM_Application)
 
   Handle(CDF_MetaDataDriver) myMetaDataDriver;
index d04cd8b9a9addec35a87c0bd847c212d975589a1..a9612a83abeaad2198a0a29257cc2041f2c0acc6 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <CDF_Directory.hxx>
 #include <CDF_DirectoryIterator.hxx>
-#include <CDF_Session.hxx>
 #include <CDM_Document.hxx>
 #include <Standard_NoSuchObject.hxx>
 
index b555fdab34a92de137319c769378967e7a883842..4fd9d7ed1cef29434c2c4acc166e326ccd42d540 100644 (file)
@@ -48,7 +48,10 @@ static void PutSlash (TCollection_ExtendedString& anXSTRING) {
 //function : CDF_FWOSDriver
 //purpose  :
 //==============================================================================
-CDF_FWOSDriver::CDF_FWOSDriver() {}
+CDF_FWOSDriver::CDF_FWOSDriver(CDM_MetaDataLookUpTable& theLookUpTable)
+: myLookUpTable (&theLookUpTable)
+{
+}
 
 //==============================================================================
 //function : Find
@@ -107,7 +110,7 @@ Handle(CDM_MetaData) CDF_FWOSDriver::MetaData(const TCollection_ExtendedString&
                                                  const TCollection_ExtendedString& /*aVersion*/)
 {
   TCollection_ExtendedString p = Concatenate(aFolder,aName);
-  return CDM_MetaData::LookUp(aFolder,aName,p,p,UTL::IsReadOnly(p));
+  return CDM_MetaData::LookUp (*myLookUpTable, aFolder, aName, p, p, UTL::IsReadOnly(p));
 }
 
 //==============================================================================
@@ -117,7 +120,7 @@ Handle(CDM_MetaData) CDF_FWOSDriver::MetaData(const TCollection_ExtendedString&
 Handle(CDM_MetaData) CDF_FWOSDriver::CreateMetaData(const Handle(CDM_Document)& aDocument,
                                                        const TCollection_ExtendedString& aFileName)
 {
-  return CDM_MetaData::LookUp(aDocument->RequestedFolder(),aDocument->RequestedName(),
+  return CDM_MetaData::LookUp(*myLookUpTable, aDocument->RequestedFolder(), aDocument->RequestedName(),
                               Concatenate(aDocument->RequestedFolder(),aDocument->RequestedName()),
                               aFileName,UTL::IsReadOnly(aFileName));
 }
@@ -193,23 +196,6 @@ TCollection_ExtendedString CDF_FWOSDriver::DefaultFolder()
   return theDefaultFolder;
 }
 
-//==============================================================================
-//function : BuildMetaData
-//purpose  :
-//==============================================================================
-Handle(CDM_MetaData) CDF_FWOSDriver::BuildMetaData(const TCollection_ExtendedString& aFileName)
-{
-
-  OSD_Path p = UTL::Path(aFileName);
-  
-  TCollection_ExtendedString f = UTL::Trek(p);
-  TCollection_ExtendedString n = UTL::Name(p);
-  n +=".";
-  n += UTL::Extension(p);
-
-  return CDM_MetaData::LookUp(f,n,aFileName,aFileName,UTL::IsReadOnly(aFileName));
-}
-
 //==============================================================================
 //function : SetName
 //purpose  :
index 6988abe2d6abf770d1b8e54fc292a7994fc1a8ac..585698a83e37273b8bf2dbcc3243df2597d7c7c6 100644 (file)
@@ -21,6 +21,8 @@
 #include <Standard_Type.hxx>
 
 #include <CDF_MetaDataDriver.hxx>
+#include <CDM_MetaDataLookUpTable.hxx>
+
 #include <Standard_Boolean.hxx>
 class TCollection_ExtendedString;
 class CDM_MetaData;
@@ -36,9 +38,10 @@ class CDF_FWOSDriver : public CDF_MetaDataDriver
 
 public:
 
-  
-  //! initializes the MetaDatadriver with its specific name.
-  Standard_EXPORT CDF_FWOSDriver();
+  //! Initializes the MetaDatadriver connected to specified look-up table.
+  //! Note that the created driver will keep reference to the table,
+  //! thus it must have life time longer than this object.
+  Standard_EXPORT CDF_FWOSDriver(CDM_MetaDataLookUpTable& theLookUpTable);
   
   //! indicate whether a file exists corresponding to the folder and the name
   Standard_EXPORT Standard_Boolean Find (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) Standard_OVERRIDE;
@@ -58,30 +61,16 @@ public:
 
   DEFINE_STANDARD_RTTIEXT(CDF_FWOSDriver,CDF_MetaDataDriver)
 
-protected:
-
-
-
-
 private:
 
-  
   Standard_EXPORT Handle(CDM_MetaData) MetaData (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) Standard_OVERRIDE;
   
   Standard_EXPORT Handle(CDM_MetaData) CreateMetaData (const Handle(CDM_Document)& aDocument, const TCollection_ExtendedString& aFileName) Standard_OVERRIDE;
   
   Standard_EXPORT static TCollection_ExtendedString Concatenate (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName);
   
-  Standard_EXPORT Handle(CDM_MetaData) BuildMetaData (const TCollection_ExtendedString& aFileName);
-
-
-
+private:
+  CDM_MetaDataLookUpTable* myLookUpTable;
 };
 
-
-
-
-
-
-
 #endif // _CDF_FWOSDriver_HeaderFile
index 5fb970e969447a7bb938028927154c6636fdc5bd..812445f603164b5ce613495ada0d0d9f57f24b66 100644 (file)
 
 #include <CDF_Application.hxx>
 #include <CDF_MetaDataDriver.hxx>
-#include <CDF_Session.hxx>
 #include <CDM_Document.hxx>
 #include <CDM_MetaData.hxx>
 #include <PCDM_ReferenceIterator.hxx>
 #include <Standard_NotImplemented.hxx>
 #include <Standard_Type.hxx>
+#include <Standard_NullObject.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <OSD_Thread.hxx>
 
@@ -77,11 +77,9 @@ void CDF_MetaDataDriver::CreateReference(const Handle(CDM_MetaData)& ,
 //purpose  : 
 //=======================================================================
 
-Handle(PCDM_ReferenceIterator) CDF_MetaDataDriver::ReferenceIterator() {
-  Standard_ThreadId anID = OSD_Thread::Current();
-  Handle(CDF_Application) anApp; 
-  CDF_Session::CurrentSession()->FindApplication(anID, anApp);
-  return new PCDM_ReferenceIterator(anApp->MessageDriver());
+Handle(PCDM_ReferenceIterator) CDF_MetaDataDriver::ReferenceIterator(const Handle(Message_Messenger)& theMessageDriver)
+{
+  return new PCDM_ReferenceIterator(theMessageDriver);
 }
 
 //=======================================================================
index 4d3d733044781404224f0981c7c55250301094ea..6c9e7ce51e9f747fb0f208e460dcec8c65c77332 100644 (file)
 #ifndef _CDF_MetaDataDriver_HeaderFile
 #define _CDF_MetaDataDriver_HeaderFile
 
-#include <Standard.hxx>
 #include <Standard_Type.hxx>
 
-#include <Standard_Transient.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Integer.hxx>
 class Standard_NotImplemented;
 class CDM_MetaData;
 class TCollection_ExtendedString;
 class CDM_Document;
 class PCDM_ReferenceIterator;
-
+class Message_Messenger;
 
 class CDF_MetaDataDriver;
 DEFINE_STANDARD_HANDLE(CDF_MetaDataDriver, Standard_Transient)
@@ -100,7 +96,7 @@ public:
   
   Standard_EXPORT virtual TCollection_ExtendedString DefaultFolder() = 0;
   
-  Standard_EXPORT virtual Handle(PCDM_ReferenceIterator) ReferenceIterator();
+  Standard_EXPORT virtual Handle(PCDM_ReferenceIterator) ReferenceIterator(const Handle(Message_Messenger)& theMessageDriver);
   
   //! calls Find with an empty version
   Standard_EXPORT Standard_Boolean Find (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName);
diff --git a/src/CDF/CDF_Session.cxx b/src/CDF/CDF_Session.cxx
deleted file mode 100644 (file)
index 91e6eb7..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-// Created on: 1997-08-08
-// Created by: Jean-Louis Frenkel
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <CDF_Application.hxx>
-#include <CDF_Directory.hxx>
-#include <CDF_FWOSDriver.hxx>
-#include <CDF_MetaDataDriver.hxx>
-#include <CDF_MetaDataDriverFactory.hxx>
-#include <CDF_Session.hxx>
-#include <PCDM.hxx>
-#include <PCDM_Reader.hxx>
-#include <Plugin.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
-#include <Standard_GUID.hxx>
-#include <Standard_MultiplyDefined.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_ExtendedString.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(CDF_Session,Standard_Transient)
-
-static Handle(CDF_Session) THE_CS;
-static Standard_Mutex THE_MUTEX;
-
-//=======================================================================
-//function : 
-//purpose  : 
-//=======================================================================
-CDF_Session::CDF_Session ()
-{  
-  Standard_MultiplyDefined_Raise_if(!THE_CS.IsNull()," a session already exists");
-}
-
-//=======================================================================
-//function : 
-//purpose  : 
-//=======================================================================
-Handle(CDF_Session) CDF_Session::Create()
-{
-  Standard_Mutex::Sentry aLocker(THE_MUTEX);
-  if (THE_CS.IsNull())
-    THE_CS = new CDF_Session;
-  return THE_CS;
-}
-
-//=======================================================================
-//function : Exists
-//purpose  : 
-//=======================================================================
-Standard_Boolean CDF_Session::Exists() {
-  return !THE_CS.IsNull();
-}
-
-//=======================================================================
-//function : CurrentSession
-//purpose  : 
-//=======================================================================
-Handle(CDF_Session) CDF_Session::CurrentSession() {
-  Standard_NoSuchObject_Raise_if(THE_CS.IsNull(), "no session has been created");
-  return THE_CS;
-}
-
-//=======================================================================
-//function : AddApplication
-//purpose  : adds the application to the session with unique name
-//=======================================================================
-Standard_Boolean CDF_Session::AddApplication(const Handle(CDF_Application)& theApp,
-  const Standard_ThreadId theID)
-{
-  return AddApplication(theApp.get(), theID);
-}
-
-//=======================================================================
-//function : AddApplication
-//purpose  : adds the application to the session with unique name
-//=======================================================================
-Standard_Boolean CDF_Session::AddApplication(const CDF_Application* theApp,
-  const Standard_ThreadId theID)
-{
-  Standard_Boolean aRetValue(Standard_False);
-  if (theApp)
-  {
-    Standard_Mutex::Sentry aLocker(THE_MUTEX);
-    if (!myAppDirectory.IsBound(theID))
-    {
-      Handle(CDF_Application) anApp(theApp);
-      aRetValue = myAppDirectory.Bind(theID, anApp);
-    }
-  }
-  return aRetValue;
-}
-
-//=======================================================================
-//function : FindApplication
-//purpose  : 
-//=======================================================================
-Standard_Boolean CDF_Session::FindApplication(const Standard_ThreadId theID, Handle(CDF_Application)& theApp) const
-{
-  Standard_Mutex::Sentry aLocker(THE_MUTEX);
-  if (myAppDirectory.IsBound(theID))
-  {
-    theApp = Handle(CDF_Application)::DownCast (myAppDirectory.Find(theID));
-    return ! theApp.IsNull();
-  }
-  return Standard_False;
-}
-//=======================================================================
-//function : RemoveApplication
-//purpose  : removes the application with name=<theName> from the session
-//=======================================================================
-Standard_Boolean CDF_Session::RemoveApplication(const Standard_ThreadId theID)
-{
-  Standard_Boolean aRetValue(Standard_False);
-  Standard_Mutex::Sentry aLocker(THE_MUTEX);
-  if (myAppDirectory.IsBound(theID))
-  {
-    aRetValue = myAppDirectory.UnBind(theID);
-  }
-  return aRetValue;
-}
diff --git a/src/CDF/CDF_Session.hxx b/src/CDF/CDF_Session.hxx
deleted file mode 100644 (file)
index ce5c3cd..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-// Created on: 1997-08-07
-// Created by: Jean-Louis Frenkel
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _CDF_Session_HeaderFile
-#define _CDF_Session_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Boolean.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Mutex.hxx>
-#include <CDM_ApplicationDirectory.hxx>
-class CDF_Directory;
-class CDF_Application;
-class CDF_MetaDataDriver;
-class Standard_NoSuchObject;
-class Standard_MultiplyDefined;
-
-class CDF_Session;
-DEFINE_STANDARD_HANDLE(CDF_Session, Standard_Transient)
-
-
-class CDF_Session : public Standard_Transient
-{
-
-public:
-
-  
-  //! returns true if a session has been created.
-  Standard_EXPORT static Standard_Boolean Exists();
-
-  //! Creates a session if it does not exists yet
-  Standard_EXPORT static Handle(CDF_Session) Create();
-
-  //! returns the only one instance of Session
-  //! that has been created.
-  Standard_EXPORT static Handle(CDF_Session) CurrentSession();
-  
-  //! returns true if theApp is added to the session
-  Standard_EXPORT Standard_Boolean AddApplication(const Handle(CDF_Application)& theApp, const Standard_ThreadId theID);
-
-  //! returns true if theApp is added to the session
-  Standard_EXPORT Standard_Boolean AddApplication(const CDF_Application* theApp, const Standard_ThreadId theID);
-
-  //! returns true if theApp is removed from the session
-  Standard_EXPORT Standard_Boolean RemoveApplication(const Standard_ThreadId theID);
-
-  //! returns true if theApp is removed from the session
-  Standard_EXPORT Standard_Boolean FindApplication(const Standard_ThreadId, Handle(CDF_Application)& theApp) const;
-
-
-friend class CDF_Application;
-
-
-  DEFINE_STANDARD_RTTIEXT(CDF_Session,Standard_Transient)
-
-protected:
-
-  //! Use "Create" session for creation of an instance
-  CDF_Session();
-
-
-
-
-private:
-
-
-  CDM_ApplicationDirectory myAppDirectory;
-  Handle(CDF_MetaDataDriver) myMetaDataDriver;
-};
-
-
-
-
-
-
-
-#endif // _CDF_Session_HeaderFile
index a60285d96944e715ee13e586091e248b46339f89..48b47339039ab556dac4cec0c9471725e6bff001 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <CDF_Application.hxx>
 #include <CDF_MetaDataDriver.hxx>
-#include <CDF_Session.hxx>
 #include <CDF_Store.hxx>
 #include <CDF_StoreList.hxx>
 #include <CDF_StoreSetNameStatus.hxx>
index 26db3dd64691bdaa936f6475a5f011fff81b1f78..5ef2668fb63dd9cafb4c63e84c81952d249a1b00 100644 (file)
@@ -18,7 +18,6 @@
 #include <CDF_Application.hxx>
 #include <CDF_MetaDataDriver.hxx>
 #include <CDF_MetaDataDriverError.hxx>
-#include <CDF_Session.hxx>
 #include <CDF_StoreList.hxx>
 #include <CDM_Document.hxx>
 #include <CDM_MetaData.hxx>
index d29b79d6bd819033483f4d2ee7fa8d5c5909994e..1bdfb4dd5371bd8819d56a5ebaacedb8404601ba 100755 (executable)
@@ -11,8 +11,6 @@ CDF_MetaDataDriver.hxx
 CDF_MetaDataDriverError.hxx
 CDF_MetaDataDriverFactory.cxx
 CDF_MetaDataDriverFactory.hxx
-CDF_Session.cxx
-CDF_Session.hxx
 CDF_Store.cxx
 CDF_Store.hxx
 CDF_StoreList.cxx
index 9bf5de603644a3a86c4d6ed9592790d97d3a8362..1f138cb7df28b340528b036ff3df28fcd7c7443a 100644 (file)
@@ -137,9 +137,9 @@ TCollection_AsciiString CDM_Application::Version() const
 //function : MetaDataLookUpTable
 //purpose  : returns the MetaData LookUpTable
 //=======================================================================
-CDM_MetaDataLookUpTable* CDM_Application::MetaDataLookUpTable()
+CDM_MetaDataLookUpTable& CDM_Application::MetaDataLookUpTable()
 {
-  return &myMetaDataLookUpTable;
+  return myMetaDataLookUpTable;
 }
 
 //=======================================================================
index fd6ab2f22b4ad677c954fbb63a919fccd69a05a8..7a1edcc4ac06e5ef627de9fc183476b840b18177 100644 (file)
@@ -70,7 +70,7 @@ public:
   Standard_EXPORT virtual TCollection_AsciiString Version() const;
   
   //! Returns MetaData LookUpTable
-  Standard_EXPORT virtual  CDM_MetaDataLookUpTable* MetaDataLookUpTable();
+  Standard_EXPORT virtual  CDM_MetaDataLookUpTable& MetaDataLookUpTable();
 
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
diff --git a/src/CDM/CDM_ApplicationDirectory.hxx b/src/CDM/CDM_ApplicationDirectory.hxx
deleted file mode 100644 (file)
index cfd00c1..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Created on: 1997-05-06
-// Created by: Jean-Louis Frenkel, Remi Lequette
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef CDM_ApplicationDirectory_HeaderFile
-#define CDM_ApplicationDirectory_HeaderFile
-
-#include <CDM_Application.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
-#include <NCollection_DataMap.hxx>
-#include <Standard_ThreadId.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<Standard_ThreadId> CDM_MapThreadIDHasher;
-typedef NCollection_DataMap<Standard_ThreadId,Handle(CDM_Application),CDM_MapThreadIDHasher> CDM_ApplicationDirectory;
-typedef NCollection_DataMap<Standard_ThreadId,Handle(CDM_Application),CDM_MapThreadIDHasher>::Iterator CDM_DataMapIteratorOfApplicationDirectory;
-
-#endif
index 189203218b2fe7f5a481deed5542cbe56f8534ac..123d43b6c1b483330facc65c9707627fb6c0d7d7 100644 (file)
@@ -536,8 +536,8 @@ void CDM_Document::SetMetaData(const Handle(CDM_MetaData)& aMetaData)
 
     aMetaData->SetDocument(this);
 
-// Update the document refencing this MetaData:
-    CDM_DataMapIteratorOfMetaDataLookUpTable it(*CDM_MetaData::LookUpTable());
+    // Update the document refencing this MetaData:
+    CDM_DataMapIteratorOfMetaDataLookUpTable it(Application()->MetaDataLookUpTable());
     for(;it.More();it.Next()) {
       const Handle(CDM_MetaData)& theMetaData=it.Value();
       if(theMetaData != aMetaData && theMetaData->IsRetrieved()) {
index e6629304a8543906275e08a5b49ef5bb49647890..2cbc5ade863488ef77593edc1493e877eaa063d7 100644 (file)
 #include <CDM_MetaData.hxx>
 #include <CDM_MetaDataLookUpTable.hxx>
 #include <CDM_Reference.hxx>
-#include <CDF_Session.hxx>
 #include <Standard_Dump.hxx>
 #include <CDF_Application.hxx>
-#include <Standard_NoSuchObject.hxx>
+#include <Standard_NullObject.hxx>
 #include <Standard_Type.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <OSD_Thread.hxx>
@@ -70,33 +69,48 @@ void CDM_MetaData::SetDocument(const Handle(CDM_Document)& aDocument) {
 void CDM_MetaData::UnsetDocument() {
   myIsRetrieved = Standard_False;
 }
-Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath,const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly) {
+Handle(CDM_MetaData) CDM_MetaData::LookUp(CDM_MetaDataLookUpTable& theLookUpTable,
+                                          const TCollection_ExtendedString& aFolder,
+                                          const TCollection_ExtendedString& aName,
+                                          const TCollection_ExtendedString& aPath,
+                                          const TCollection_ExtendedString& aFileName,
+                                          const Standard_Boolean ReadOnly)
+{
   Handle(CDM_MetaData) theMetaData;
   TCollection_ExtendedString aConventionalPath=aPath;
   aConventionalPath.ChangeAll('\\','/');
-  CDM_MetaDataLookUpTable* aLookUpTable = LookUpTable();
-  if (!aLookUpTable) return theMetaData;
-  if(!aLookUpTable->IsBound(aConventionalPath)) {
+  if(!theLookUpTable.IsBound(aConventionalPath))
+  {
     theMetaData = new CDM_MetaData(aFolder,aName,aPath,aFileName,ReadOnly);
-    aLookUpTable->Bind(aConventionalPath, theMetaData);
+    theLookUpTable.Bind(aConventionalPath, theMetaData);
   }
   else
-    theMetaData = aLookUpTable->Find(aConventionalPath);
+  {
+    theMetaData = theLookUpTable.Find(aConventionalPath);
+  }
   
   return theMetaData;
 }
-Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aVersion, const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly) {
+Handle(CDM_MetaData) CDM_MetaData::LookUp(CDM_MetaDataLookUpTable& theLookUpTable,
+                                          const TCollection_ExtendedString& aFolder,
+                                          const TCollection_ExtendedString& aName,
+                                          const TCollection_ExtendedString& aPath,
+                                          const TCollection_ExtendedString& aVersion,
+                                          const TCollection_ExtendedString& aFileName,
+                                          const Standard_Boolean ReadOnly)
+{
   Handle(CDM_MetaData) theMetaData;
   TCollection_ExtendedString aConventionalPath=aPath;
   aConventionalPath.ChangeAll('\\','/');
-  CDM_MetaDataLookUpTable* aLookUpTable = LookUpTable();
-  if (!aLookUpTable) return theMetaData;
-  if(!aLookUpTable->IsBound(aConventionalPath)) {
+  if(!theLookUpTable.IsBound(aConventionalPath))
+  {
     theMetaData = new CDM_MetaData(aFolder,aName,aPath,aVersion,aFileName,ReadOnly);
-    aLookUpTable->Bind(aConventionalPath,theMetaData);
+    theLookUpTable.Bind(aConventionalPath,theMetaData);
   }
   else
-    theMetaData = aLookUpTable->Find(aConventionalPath);
+  {
+    theMetaData = theLookUpTable.Find(aConventionalPath);
+  }
   
   return theMetaData;
 }
@@ -134,14 +148,6 @@ Standard_OStream& CDM_MetaData::operator << (Standard_OStream& anOStream) {
   return Print(anOStream);
 }
 
-CDM_MetaDataLookUpTable* CDM_MetaData::LookUpTable() {
-  Handle(CDF_Session) aSession = CDF_Session::Create();
-  Handle(CDF_Application) anApp;
-  CDM_MetaDataLookUpTable* pLookUpTable(NULL);
-  if (aSession->FindApplication(OSD_Thread::Current(), anApp))
-    return anApp->MetaDataLookUpTable();
-  return pLookUpTable;
-}
 Standard_Integer CDM_MetaData::DocumentVersion(const Handle(CDM_Application)& anApplication) {
   if(myDocumentVersion==0) myDocumentVersion=anApplication->DocumentVersion(this);
   return myDocumentVersion;
index ca991716fc0014f9fd99bb8eb6a48b0ac0965ca4..9039ddce8153e8cd1fd918175615bbb8c6fb74e2 100644 (file)
@@ -45,11 +45,21 @@ class CDM_MetaData : public Standard_Transient
 
 public:
 
-  
-  Standard_EXPORT static Handle(CDM_MetaData) LookUp (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-  
-  Standard_EXPORT static Handle(CDM_MetaData) LookUp (const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aVersion, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-  
+  Standard_EXPORT static Handle(CDM_MetaData) LookUp (CDM_MetaDataLookUpTable& theLookUpTable,
+                                                      const TCollection_ExtendedString& aFolder,
+                                                      const TCollection_ExtendedString& aName,
+                                                      const TCollection_ExtendedString& aPath,
+                                                      const TCollection_ExtendedString& aFileName,
+                                                      const Standard_Boolean ReadOnly);
+
+  Standard_EXPORT static Handle(CDM_MetaData) LookUp (CDM_MetaDataLookUpTable& theLookUpTable,
+                                                      const TCollection_ExtendedString& aFolder,
+                                                      const TCollection_ExtendedString& aName,
+                                                      const TCollection_ExtendedString& aPath,
+                                                      const TCollection_ExtendedString& aVersion,
+                                                      const TCollection_ExtendedString& aFileName,
+                                                      const Standard_Boolean ReadOnly);
+
   Standard_EXPORT Standard_Boolean IsRetrieved() const;
   
   Standard_EXPORT Handle(CDM_Document) Document() const;
@@ -101,23 +111,26 @@ friend
 
   DEFINE_STANDARD_RTTIEXT(CDM_MetaData,Standard_Transient)
 
-protected:
+private:
 
+  CDM_MetaData (const TCollection_ExtendedString& aFolder,
+                const TCollection_ExtendedString& aName,
+                const TCollection_ExtendedString& aPath,
+                const TCollection_ExtendedString& aFileName,
+                const Standard_Boolean ReadOnly);
 
+  CDM_MetaData (const TCollection_ExtendedString& aFolder,
+                const TCollection_ExtendedString& aName,
+                const TCollection_ExtendedString& aPath,
+                const TCollection_ExtendedString& aVersion,
+                const TCollection_ExtendedString& aFileName,
+                const Standard_Boolean ReadOnly);
 
+  void SetDocument (const Handle(CDM_Document)& aDocument);
 
-private:
+  Standard_Integer DocumentVersion (const Handle(CDM_Application)& anApplication);
 
-  
-  Standard_EXPORT CDM_MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-  
-  Standard_EXPORT CDM_MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aVersion, const TCollection_ExtendedString& aFileName, const Standard_Boolean ReadOnly);
-  
-  Standard_EXPORT void SetDocument (const Handle(CDM_Document)& aDocument);
-  
-  Standard_EXPORT static CDM_MetaDataLookUpTable* LookUpTable();
-  
-  Standard_EXPORT Standard_Integer DocumentVersion (const Handle(CDM_Application)& anApplication);
+private:
 
   Standard_Boolean myIsRetrieved;
   CDM_DocumentPointer myDocument;
index 46b7bc4094c90a3e6219bda91a7cd9b0563ffaa7..769a0835b51bd26d5a752dfb4d3b94dd6a66631f 100644 (file)
@@ -16,7 +16,6 @@ CDM_MetaData.cxx
 CDM_MetaData.hxx
 CDM_MetaDataLookUpTable.hxx
 CDM_NamesDirectory.hxx
-CDM_ApplicationDirectory.hxx
 CDM_Reference.cxx
 CDM_Reference.hxx
 CDM_ReferenceIterator.cxx
index acc52dbf81f824757ec67134fc001541e29bd1d8..1de7275b99e9242eef17395f3b542fd4ece80b5a 100644 (file)
@@ -13,8 +13,6 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-
-#include <CDF_Session.hxx>
 #include <DBRep.hxx>
 #include <DDocStd.hxx>
 #include <DDocStd_DrawDocument.hxx>
index a3554f24a85a89c517d3b3498a36825850521ee6..2ad5f1383f97e9dae8b44b79cfcb96e130980f3b 100644 (file)
@@ -53,9 +53,10 @@ void PCDM_ReferenceIterator::LoadReferences(const Handle(CDM_Document)& aDocumen
                                            const Handle(CDM_MetaData)& aMetaData, 
                                            const Handle(CDM_Application)& anApplication, 
                                            const Standard_Boolean UseStorageConfiguration) {
-  for (Init(aMetaData);More();Next()) {
-    aDocument->CreateReference(MetaData(UseStorageConfiguration),ReferenceIdentifier(),
-                              anApplication,DocumentVersion(),UseStorageConfiguration);
+  for (Init(aMetaData);More();Next())
+  {
+    aDocument->CreateReference(MetaData(anApplication->MetaDataLookUpTable(),UseStorageConfiguration),
+                               ReferenceIdentifier(),anApplication,DocumentVersion(),UseStorageConfiguration);
   }
 }
 
@@ -96,7 +97,9 @@ void PCDM_ReferenceIterator::Next() {
 //purpose  : 
 //=======================================================================
 
-Handle(CDM_MetaData) PCDM_ReferenceIterator::MetaData(const Standard_Boolean ) const {
+Handle(CDM_MetaData) PCDM_ReferenceIterator::MetaData(CDM_MetaDataLookUpTable& theLookUpTable,
+                                                      const Standard_Boolean ) const
+{
   
   TCollection_ExtendedString theFolder,theName;
   TCollection_ExtendedString theFile=myReferences(myIterator).FileName();
@@ -140,8 +143,9 @@ Handle(CDM_MetaData) PCDM_ReferenceIterator::MetaData(const Standard_Boolean ) c
   theName   = UTL::Name(p); theName+= UTL::Extension(p);
 #endif  // _WIN32
   
-  return CDM_MetaData::LookUp(theFolder,theName,theFile,theFile,UTL::IsReadOnly(theFile));
+  return CDM_MetaData::LookUp(theLookUpTable, theFolder, theName, theFile, theFile, UTL::IsReadOnly(theFile));
 }
+
 //=======================================================================
 //function : ReferenceIdentifier
 //purpose  : 
index be0b52378179d9c54b4cc80f40f00749ebc99866..ed64f568720d5a897ca2ef3c7ef0c084b833b576 100644 (file)
 #include <Standard_Type.hxx>
 
 #include <PCDM_SequenceOfReference.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Boolean.hxx>
+#include <CDM_MetaDataLookUpTable.hxx>
+
 class Message_Messenger;
 class CDM_Document;
 class CDM_MetaData;
 class CDM_Application;
 
-
 class PCDM_ReferenceIterator;
 DEFINE_STANDARD_HANDLE(PCDM_ReferenceIterator, Standard_Transient)
 
@@ -64,18 +62,18 @@ private:
   
   Standard_EXPORT virtual void Next();
   
-  Standard_EXPORT virtual Handle(CDM_MetaData) MetaData (const Standard_Boolean UseStorageConfiguration) const;
+  Standard_EXPORT virtual Handle(CDM_MetaData) MetaData (CDM_MetaDataLookUpTable& theLookUpTable,
+                                                         const Standard_Boolean UseStorageConfiguration) const;
   
   Standard_EXPORT virtual Standard_Integer ReferenceIdentifier() const;
   
   //! returns the version of the document in the reference
   Standard_EXPORT virtual Standard_Integer DocumentVersion() const;
 
+private:
   PCDM_SequenceOfReference myReferences;
   Standard_Integer myIterator;
   Handle(Message_Messenger) myMessageDriver;
-
-
 };
 
 
index 4dba1d03c45354951f620a5e230932f47c4da9d1..3ea3d46afd5102827b57e60642f753754f14251d 100644 (file)
@@ -3065,7 +3065,6 @@ void* threadFunction(void* theArgs)
       }
     }
     args->finished = true;
-    anApp->RemoveFromSession();
   }
   catch (...)
   {
@@ -3794,6 +3793,83 @@ static Standard_Integer OCC31320(Draw_Interpretor& di, Standard_Integer argc, co
 
 }
 
+#include <BinXCAFDrivers.hxx>
+#include <Message.hxx>
+namespace
+{
+  class QABugs_XdeLoader : public OSD_Thread
+  {
+  public:
+    QABugs_XdeLoader (const Handle(TDocStd_Application)& theXdeApp,
+                      const Handle(TDocStd_Document)&    theXdeDoc,
+                      const TCollection_AsciiString&     theFilePath)
+    : OSD_Thread (performThread),
+      myXdeApp (theXdeApp), myXdeDoc (theXdeDoc), myFilePath (theFilePath) {}
+
+  private:
+    void perform()
+    {
+      Handle(TDocStd_Document) aNewDoc;
+      const PCDM_ReaderStatus aReaderStatus = myXdeApp->Open (myFilePath, aNewDoc);
+      if (aReaderStatus != PCDM_RS_OK)
+      {
+        Message::SendFail ("Error occurred while reading the file");
+        return;
+      }
+      myXdeDoc = aNewDoc;
+      Message::SendInfo() << "Info: document has been opened";
+    }
+
+    static Standard_Address performThread (Standard_Address theData)
+    {
+      QABugs_XdeLoader* aLoader = (QABugs_XdeLoader* )theData;
+      OSD::SetThreadLocalSignal (OSD_SignalMode_Set, false);
+      try
+      {
+        OCC_CATCH_SIGNALS
+        aLoader->perform();
+      }
+      catch (Standard_Failure const& theExcep)
+      {
+        Message::SendFail() << "Error: unexpected exception " << theExcep;
+        return 0;
+      }
+      return 0;
+    }
+  private:
+    Handle(TDocStd_Application) myXdeApp;
+    Handle(TDocStd_Document)    myXdeDoc;
+    TCollection_AsciiString     myFilePath;
+  };
+}
+
+//=======================================================================
+//function : OCC31785
+//purpose  : Try reading XBF file in background thread
+//=======================================================================
+static Standard_Integer OCC31785 (Draw_Interpretor& theDI,
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
+{
+  if (theNbArgs != 2)
+  {
+    theDI << "Syntax error: wrong number of arguments\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aFileName (theArgVec[1]);
+
+  Handle(TDocStd_Application) anXdeApp = new TDocStd_Application();
+  BinXCAFDrivers::DefineFormat (anXdeApp);
+
+  Handle(TDocStd_Document) anXdeDoc;
+  anXdeApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), anXdeDoc);
+  QABugs_XdeLoader aLoader (anXdeApp, anXdeDoc, aFileName);
+  aLoader.Run (&aLoader);
+  aLoader.Wait();
+  return 0;
+}
+
 void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -3865,5 +3941,9 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
 
   theCommands.Add("OCC31320", "OCC31320 DocName ObjName : tests remove of the children GetFather method if father is removed", __FILE__, OCC31320, group);
 
+  theCommands.Add("OCC31785",
+                  "OCC31785 file.xbf : test reading XBF file in another thread",
+                  __FILE__, OCC31785, group);
+
   return;
 }
index 076d8b048cfdde0355d03d37af3e7e0fa0d90f77..cd9d0f37c8d4e922c21d99bea333d29e4329a938 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <CDF_Directory.hxx>
 #include <CDF_DirectoryIterator.hxx>
-#include <CDF_Session.hxx>
 #include <CDF_Store.hxx>
 #include <PCDM_RetrievalDriver.hxx>
 #include <PCDM_StorageDriver.hxx>
@@ -46,12 +45,10 @@ IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Application,CDF_Application)
 TDocStd_Application::TDocStd_Application()
         : myIsDriverLoaded (Standard_True)
 {
-  AddToSession();
   if(myMetaDataDriver.IsNull())
     myIsDriverLoaded = Standard_False;
 }
 
-
 //=======================================================================
 //function : IsDriverLoaded
 //purpose  :
@@ -156,9 +153,7 @@ void TDocStd_Application::WritingFormats(TColStd_SequenceOfAsciiString &theForma
 
 Standard_Integer TDocStd_Application::NbDocuments() const
 {
-  if (!CDF_Session::Exists())
-    throw Standard_DomainError("TDocStd_Application::NbDocuments");
-  return this->myDirectory->Length();
+  return myDirectory->Length();
 }
 
 //=======================================================================
@@ -168,8 +163,6 @@ Standard_Integer TDocStd_Application::NbDocuments() const
 
 void TDocStd_Application::GetDocument(const Standard_Integer index,Handle(TDocStd_Document)& aDoc) const
 {
-  if (!CDF_Session::Exists())
-    throw Standard_DomainError("TDocStd_Application::NbDocuments");
   CDF_DirectoryIterator it (myDirectory);
   Standard_Integer current = 0;
   for (;it.MoreDocument();it.NextDocument()) {
@@ -601,19 +594,6 @@ void TDocStd_Application::OnCommitTransaction (const Handle(TDocStd_Document)&)
   // nothing to do on this level
 }
 
-//
-void TDocStd_Application::AddToSession()
-{
-  Handle(CDF_Session) S = CDF_Session::Create();
-  S->AddApplication(this, OSD_Thread::Current());
-}
-
-Standard_Boolean TDocStd_Application::RemoveFromSession()
-{
-  Handle(CDF_Session) aSession = CDF_Session::Create();
-  return aSession->RemoveApplication(OSD_Thread::Current());
-}
-
 //=======================================================================
 //function : DumpJson
 //purpose  : 
index bc9b3c7e4d5dd497f52e2c0c0ad7e882173898be..e0d421e9d56d2ce7f8ba1cbf1242337be57b465a 100644 (file)
@@ -283,20 +283,12 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
-  //! Remove this application from the current session
-  Standard_EXPORT Standard_Boolean RemoveFromSession();
-
   DEFINE_STANDARD_RTTIEXT(TDocStd_Application, CDF_Application)
 
 protected:
 
   Handle(Resource_Manager) myResources;
   Standard_Boolean myIsDriverLoaded;
-
-private:
-
-  //! Add this application to the current session (register in internal container)
-  void AddToSession();
 };
 
 #endif // _TDocStd_Application_HeaderFile
index cfaa6d7997386f3d04d318b6b10bdda5a977e0f3..32d736b68b067f5c05293b0ed9ce0bd217739850 100755 (executable)
@@ -27,6 +27,7 @@ TKIGES
 TKXSBase
 TKMesh
 TKXCAF
+TKBinXCAF
 TKSTEP
 TKSTEPBase
 TKXDESTEP
index 17bb84ebc930410e93f6426f85a4b708285bd84d..81e9279a4b9bf560e22231fab4f129578b70a81e 100644 (file)
@@ -25,8 +25,6 @@
 #include <Message_Msg.hxx>
 #include <Message_MsgFile.hxx>
 #include <Resource_Manager.hxx>
-#include <CDF_Session.hxx>
-#include <OSD_Thread.hxx>
 #include <stdio.h>
 
 #include "TObj_TObj_msg.pxx"
@@ -39,21 +37,8 @@ IMPLEMENT_STANDARD_RTTIEXT(TObj_Application,TDocStd_Application)
 //=======================================================================
 Handle(TObj_Application) TObj_Application::GetInstance()
 {
-  Handle(CDF_Session) aSession = CDF_Session::Create();
-  Handle(CDF_Application) anApp;
-  if (aSession->FindApplication(OSD_Thread::Current(), anApp))
-  {
-    Handle(TObj_Application) aTObjApp = Handle(TObj_Application)::DownCast(anApp);
-    if (!aTObjApp.IsNull())
-      return aTObjApp;
-    // If in session application of another type is already registered, use this global
-    // application, alone, outside of the session (as a workaround for DRAW scripting where
-    // many kinds of applications can be required).
-    static Handle(TObj_Application) THE_TOBJ_APP(new TObj_Application);
-    return THE_TOBJ_APP;
-  }
-  // It will register this application in the session.
-  return new TObj_Application;
+  static Handle(TObj_Application) THE_TOBJ_APP(new TObj_Application);
+  return THE_TOBJ_APP;
 }
 
 //=======================================================================
index 9d6512d9df5d7a8c89e032afbcae299b82d95d36..35bf5d345211d68f7ea6c6b7ffa6f5f841fcda43 100644 (file)
@@ -396,7 +396,8 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
         theName   = UTL::Name(p); theName+= UTL::Extension(p);
 #endif  // _WIN32
         
-        Handle(CDM_MetaData) aMetaData =  CDM_MetaData::LookUp(theFolder,theName,aPath,aPath,UTL::IsReadOnly(aFileName));
+        Handle(CDM_MetaData) aMetaData =
+          CDM_MetaData::LookUp(theApplication->MetaDataLookUpTable(), theFolder, theName, aPath, aPath, UTL::IsReadOnly(aFileName));
 ////////////
         theNewDocument->CreateReference(aMetaData,aRefId,
              theApplication,aDocumentVersion,Standard_False);
diff --git a/tests/bugs/caf/bug31785 b/tests/bugs/caf/bug31785
new file mode 100644 (file)
index 0000000..e4c64b5
--- /dev/null
@@ -0,0 +1,10 @@
+puts "==========="
+puts "0031785: \[REGRESSION\] Application Framework - application crashes on reading XBF document in background thread"
+puts "==========="
+
+pload XDE QAcommands
+XNewDoc D
+XSave D ${imagedir}/bug31785.xbf
+Close D
+
+OCC31785 ${imagedir}/bug31785.xbf
index 10816585d6ee6f25562afccf0cd2bf61bdb22158..6ae5f5c016f074193757892b4ac6d5b41e8f4e92 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <inspector/DFBrowser_Communicator.hxx>
 
-#include <CDF_Session.hxx>
 #include <inspector/DFBrowser_Module.hxx>
 #include <inspector/DFBrowser_Window.hxx>
 
index a4e25b4b10dc0b79bb76d2c7c2134d2014afbfc5..b7e94c7ffbe1ea4a40e01e5ac42e940e40500891 100644 (file)
@@ -19,8 +19,6 @@
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_ListOfInteractive.hxx>
 
-#include <CDF_Session.hxx>
-
 #include <inspector/DFBrowserPane_AttributePaneAPI.hxx>
 
 #include <inspector/DFBrowser_AttributePaneStack.hxx>
@@ -439,15 +437,6 @@ void DFBrowser_Window::Init (const NCollection_List<Handle(Standard_Transient)>&
     }
     return;
   }
-  else
-  {
-    if (anApplication.IsNull() && CDF_Session::Exists()) {
-      Standard_ThreadId anID = OSD_Thread::Current();
-      Handle(CDF_Application) anApp;
-      CDF_Session::CurrentSession()->FindApplication(anID, anApp);
-      anApplication = Handle(TDocStd_Application)::DownCast (anApp);
-    }
-  }
 
   myModule = new DFBrowser_Module();
   myModule->CreateViewModel (myMainWindow);
@@ -503,28 +492,18 @@ void DFBrowser_Window::OpenFile (const TCollection_AsciiString& theFileName)
   anOCAFViewModel->Reset();
 
   //! close previous documents to open new document
-  Handle(TDocStd_Application) anApplication;
-  if (CDF_Session::Exists())
+  Handle(TDocStd_Application) anApplication = myModule->GetTDocStdApplication();
+  if (!anApplication.IsNull())
   {
-    Handle(CDF_Session) aSession = CDF_Session::CurrentSession();
-    if (!aSession.IsNull())
+    for (int aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
     {
-      Standard_ThreadId anID = OSD_Thread::Current();
-      Handle(CDF_Application) anApp;
-      CDF_Session::CurrentSession()->FindApplication(anID, anApp);
-      anApplication = Handle(TDocStd_Application)::DownCast (anApp);
-      if (!anApplication.IsNull())
-      {
-        for (int aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
-        {
-          Handle(TDocStd_Document) aDocument;
-          anApplication->GetDocument (aDocId, aDocument);
-          if (!aDocument.IsNull())
-            anApplication->Close (aDocument);
-        }
-      }
+      Handle(TDocStd_Document) aDocument;
+      anApplication->GetDocument (aDocId, aDocument);
+      if (!aDocument.IsNull())
+        anApplication->Close (aDocument);
     }
   }
+
   //! open new document
   bool isSTEPFileName = false;
   anApplication = DFBrowser_OpenApplication::OpenApplication (theFileName, isSTEPFileName);