From 3fa174afbd949b8d2063384692232e2725360326 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 11 May 2017 09:49:09 +0300 Subject: [PATCH] Issue #2156 Impossible to valid the sketch: better debug information about store/restore current feature in document --- src/ModuleBase/ModuleBase_Tools.cpp | 8 +++++ src/ModuleBase/ModuleBase_Tools.h | 5 ++++ src/XGUI/XGUI_OperationMgr.cpp | 45 +++++++++++++---------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 53ee53347..c50573294 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -267,6 +267,14 @@ QAction* createAction(const QIcon& theIcon, const QString& theText, } #ifdef _DEBUG +QString objectName(const ObjectPtr& theObj) +{ + if (!theObj.get()) + return ""; + + return theObj->data()->name().c_str(); +} + QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) { QString aFeatureStr = "feature"; diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 5b9e658d0..c99254696 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -132,6 +132,11 @@ MODULEBASE_EXPORT QAction* createAction(const QIcon& theIcon, const QString& the const QString& theStatusTip = QString()); #ifdef _DEBUG +/// Returns name of data of the object if it is not NULL +/// \param theObj an object +/// \return a string +MODULEBASE_EXPORT QString objectName(const ObjectPtr& theObj); + /// Converts the object to the feature or a result and generate information string /// \param theObj an object /// \param isUseAttributesInfo a flag whether the attribute values information is used diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 61adc99ea..ac9924711 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -351,6 +351,12 @@ void XGUI_OperationMgr::setCurrentFeature(const FeaturePtr& theFeature) aMgr->startOperation(QString("Set current feature: %1") .arg(theFeature->getKind().c_str()).toStdString()); aDoc->setCurrentFeature(theFeature, false); +#ifdef DEBUG_CURRENT_FEATURE + qDebug(QString(" document->setCurrentFeature(false) = %1 SET").arg( + ModuleBase_Tools::objectName( + ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); +#endif + if (!aIsOp) aMgr->finishOperation(); } @@ -456,12 +462,12 @@ void XGUI_OperationMgr::onBeforeOperationStarted() #ifdef DEBUG_CURRENT_FEATURE FeaturePtr aFeature = aFOperation->feature(); QString aKind = aFeature ? aFeature->getKind().c_str() : ""; - qDebug(QString("onBeforeOperationStarted(), edit operation = %1, feature = %2") + qDebug(""); + qDebug(QString("onBeforeOperationStarted() isEditOperation = %1, feature = %2") .arg(aFOperation->isEditOperation()) - .arg(ModuleBase_Tools::objectInfo(aFeature)).toStdString().c_str()); - - qDebug(QString("\tdocument->currentFeature(false) = %1").arg( - ModuleBase_Tools::objectInfo( + .arg(ModuleBase_Tools::objectName(aFeature)).toStdString().c_str()); + qDebug(QString(" document->currentFeature(false) = %1 : DO: setPreviousCurrentFeature").arg( + ModuleBase_Tools::objectName( ModelAPI_Session::get()->activeDocument()->currentFeature(false))) .toStdString().c_str()); #endif @@ -469,6 +475,11 @@ void XGUI_OperationMgr::onBeforeOperationStarted() if (aFOperation->isEditOperation()) {// it should be performed by the feature edit only // in create operation, the current feature is changed by addFeature() aDoc->setCurrentFeature(aFOperation->feature(), false); +#ifdef DEBUG_CURRENT_FEATURE + qDebug(QString(" document->setCurrentFeature(false) = %1").arg( + ModuleBase_Tools::objectName( + ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); +#endif // this is the only place where flushes must be called after setCurrentFeature for the // current moment: after this the opertion is not finished, so, the ObjectBrowser // state may be corrupted (issue #1457) @@ -478,14 +489,6 @@ void XGUI_OperationMgr::onBeforeOperationStarted() static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED); aLoop->flush(aDeleteEvent); } - -#ifdef DEBUG_CURRENT_FEATURE - qDebug("\tdocument->setCurrentFeature"); - qDebug(QString("\tdocument->currentFeature(false) = %1").arg( - ModuleBase_Tools::objectInfo( - ModelAPI_Session::get()->activeDocument()->currentFeature(false))) - .toStdString().c_str()); -#endif } } @@ -520,12 +523,11 @@ void XGUI_OperationMgr::onBeforeOperationCommitted() if (aFOperation) { #ifdef DEBUG_CURRENT_FEATURE QString aKind = aFOperation->feature()->getKind().c_str(); - qDebug(QString("onBeforeOperationCommitted(), edit operation = %1, feature = %2") + qDebug(QString("onBeforeOperationCommitted() isEditOperation = %1, feature = %2") .arg(aFOperation->isEditOperation()) - .arg(ModuleBase_Tools::objectInfo(aFOperation->feature())).toStdString().c_str()); - - qDebug(QString("\tdocument->currentFeature(false) = %1").arg( - ModuleBase_Tools::objectInfo( + .arg(ModuleBase_Tools::objectName(aFOperation->feature())).toStdString().c_str()); + qDebug(QString(" document->currentFeature(false) = %1").arg( + ModuleBase_Tools::objectName( ModelAPI_Session::get()->activeDocument()->currentFeature(false))) .toStdString().c_str()); #endif @@ -543,13 +545,6 @@ void XGUI_OperationMgr::onBeforeOperationCommitted() if (myOperations.front() != aFOperation) setCurrentFeature(aFOperation->previousCurrentFeature()); } -#ifdef DEBUG_CURRENT_FEATURE - qDebug("\tdocument->setCurrentFeature"); - qDebug(QString("\tdocument->currentFeature(false) = %1").arg( - ModuleBase_Tools::objectInfo( - ModelAPI_Session::get()->activeDocument()->currentFeature(false))) - .toStdString().c_str()); -#endif ModuleBase_IModule* aModule = myWorkshop->module(); if (aModule) aModule->beforeOperationStopped(aFOperation); -- 2.30.2