MantisBT - Open CASCADE
View Issue Details
0032125Open CASCADE[OCCT] OCCT:Application Frameworkpublic2021-02-10 10:342021-07-20 12:07
abv 
mpv 
normalminor 
resolvedopen 
 
[OCCT] 7.6.0* 
0032125: Application Framework, OCAF - need to have adequate message if document cannot be saved due to unrecognized format
In DRAW:

> source samples/tcl/xde.tcl
> SaveAs D ./xde.cbf
Error saving document: Write failure

The failure is apparently because the format of the document set at creation in the script as "XCAF" does not match any of the supported persistence formats (e.g. "BinXCAF").

The error message should provide indication on the reason of the failure (unrecognized format).
Fixed: http://jenkins-test-occt/view/CR32125_1-master-VRO/view/COMPARE/, [^] could you revise please a branch CR32125_1?
No tags attached.
Issue History
2021-02-10 10:34abvNew Issue
2021-02-10 10:34abvAssigned To => mpv
2021-02-10 10:42kgvSummaryOCAF - need to have adequate message if document cannot be saved due to unrecognized format => Application Framework, OCAF - need to have adequate message if document cannot be saved due to unrecognized format
2021-07-19 19:23gitNote Added: 0102660
2021-07-19 21:12gitNote Added: 0102662
2021-07-20 05:03gitNote Added: 0102667
2021-07-20 07:08vroStatusnew => resolved
2021-07-20 07:08vroSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=25517#r25517
2021-07-20 12:05kgvNote Added: 0102674
2021-07-20 12:06kgvNote Edited: 0102674bug_revision_view_page.php?bugnote_id=102674#r25519
2021-07-20 12:07kgvNote Added: 0102675

Notes
(0102660)
git   
2021-07-19 19:23   
Branch CR32125 has been created by vro.

SHA-1: c723a13eee36471898b6e22478cead511e9a3ecf


Detailed log of new commits:

Author: vro
Date: Mon Jul 19 19:22:36 2021 +0300

    0032125: Application Framework, OCAF - need to have adequate message if document cannot be saved due to unrecognized format
    
    A list of storage statuses (PCDM_StoreStatus) is extended for PCDM_SS_UnrecognizedFormat. It is set if
    - extension of a document file name is not defined (the extension doesn't correspond to any declared file formats) or
    - a storage driver is not found for the document storage format.
    
    Modifications:
    CDF_StoreList.cxx: a unique exception is raised in case of the driver is not found by the document format.
    PCDM_StoreStatus.hxx: a new enumeration value is added - PCDM_SS_UnrecognizedFormat.
    DDocStd_ApplicationCommands.cxx: processing of a new enumeration value by the draw-command.
(0102662)
git   
2021-07-19 21:12   
Branch CR32125 has been updated by vro.

SHA-1: 01b392363e6e525a62af078def15e7521d5b3d5b


Detailed log of new commits:

Author: vro
Date: Mon Jul 19 21:11:50 2021 +0300

    0032125: Application Framework, OCAF - need to have adequate message if document cannot be saved due to unrecognized format
    
    Modifications:
    - XDEDRAW.cxx: processed a new enumeration value PCDM_SS_UnrecognizedFormat by saveDoc draw-command.

(0102667)
git   
2021-07-20 05:03   
Branch CR32125_1 has been created by vro.

SHA-1: fbeed435b4536e4c6ec287cc267b40328901a954


Detailed log of new commits:

Author: vro
Date: Tue Jul 20 05:02:43 2021 +0300

    0032125: Application Framework, OCAF - need to have adequate message if document cannot be saved due to unrecognized format
    
    A list of storage statuses (PCDM_StoreStatus) is extended for PCDM_SS_UnrecognizedFormat. It is set if
    - extension of a document file name is not defined (the extension doesn't correspond to any declared file formats) or
    - a storage driver is not found for the document storage format.
    
    Modifications:
    - CDF_StoreList.cxx: a unique exception is raised in case of the driver is not found by the document format.
    - PCDM_StoreStatus.hxx: a new enumeration value is added - PCDM_SS_UnrecognizedFormat.
    - DDocStd_ApplicationCommands.cxx: processing of a new enumeration value PCDM_SS_UnrecognizedFormat by SaveAs draw-command.
    - XDEDRAW.cxx: processing of a new enumeration value PCDM_SS_UnrecognizedFormat by saveDoc draw-command.
(0102674)
kgv   
2021-07-20 12:05   
(edited on: 2021-07-20 12:06)
+    catch (Standard_ProgramError const& anException) {
+      CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver not found; 
reason:"));
+      status = PCDM_SS_UnrecognizedFormat;

Using general-purpose exception to be treated as specific error looks confusing (cannot say if it is error-prone in this context).

void CDF_Store::Realize (const Message_ProgressRange& theRange)
{
  Standard_ProgramError_Raise_if(!myList->IsConsistent(),"information are missing");
  Handle(CDM_MetaData) m;
  myText = "";
  myStatus = myList->Store(m, myText, theRange);
  if(myStatus==PCDM_SS_OK) myPath = m->Path();
}
...
PCDM_StoreStatus TDocStd_Application::SaveAs (const Handle(TDocStd_Document)& theDoc,
                                              const TCollection_ExtendedString& path,
                                              const Message_ProgressRange& theRange)
{
...
  try {
    OCC_CATCH_SIGNALS
    storer.Realize (theRange);
  }
  catch (Standard_Failure const& anException) {
    if (!MessageDriver().IsNull()) {
      TCollection_ExtendedString aString (anException.GetMessageString());
      MessageDriver()->Send(aString.ToExtString(), Message_Fail);
    }
  }

CDF_Store stores detailed error description as class field CDF_Store::myText, which is inaccessible to the used of TDocStd_Application::SaveAs() as only PCDM_StoreStatus enumeration value is returned.

Maybe it worth redirecting this message on failure state to the MessageDriver like it is done in case of unhandled exception?
Or at least with Message_Trace level...

(0102675)
kgv   
2021-07-20 12:07   
--- a/src/PCDM/PCDM_StoreStatus.hxx
+++ b/src/PCDM/PCDM_StoreStatus.hxx
@@ -27,7 +27,8 @@ PCDM_SS_Failure,
 PCDM_SS_Doc_IsNull,
 PCDM_SS_No_Obj,
 PCDM_SS_Info_Section_Error,
-PCDM_SS_UserBreak
+PCDM_SS_UserBreak,
+PCDM_SS_UnrecognizedFormat

Would be nice adding documentation to each enumeration value (new and old ones) in scope of this patch.