double aMinValue = 1.e-5;
if(theArguments.size() == 1) {
std::list<std::string>::const_iterator anIt = theArguments.begin();
- char *aErr;
double aValue = Config_PropManager::stringToDouble((*anIt).c_str());
if(aValue != 0) {
// very probably ok
}
//=======================================================================
-bool Model_Application::isLoadByDemand(std::string theID)
+bool Model_Application::isLoadByDemand(std::string theID, const int theDocIndex)
{
- return myLoadedByDemand.find(theID) != myLoadedByDemand.end();
+ return myLoadedByDemand.find(theID) != myLoadedByDemand.end() &&
+ myLoadedByDemand[theID] == theDocIndex;
}
//=======================================================================
//! Defines that specified document must be loaded by demand
void setLoadByDemand(std::string theID, const int theDocID);
//! Returns true if specified document must be loaded by demand
- bool isLoadByDemand(std::string theID);
+ bool isLoadByDemand(std::string theID, const int theDocIndex);
//! Closes and removes the documents that are not loaded by demand and
//! not in the given list
void removeUselessDocuments(std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs);
}
if (!aDocRef->value().get()) { // create (or open) a document if it is not yet created
Handle(Model_Application) anApp = Model_Application::getApplication();
- if (anApp->isLoadByDemand(data()->name())) {
+ if (anApp->isLoadByDemand(data()->name(), aDocRef->docId())) {
anApp->loadDocument(data()->name(), aDocRef->docId()); // if it is just ne part, load may fail
} else {
anApp->createDocument(aDocRef->docId());
return aResult;
}
-bool Model_Session::isLoadByDemand(const std::string theDocID)
+bool Model_Session::isLoadByDemand(const std::string theDocID, const int theDocIndex)
{
- return Model_Application::getApplication()->isLoadByDemand(theDocID);
+ return Model_Application::getApplication()->isLoadByDemand(theDocID, theDocIndex);
}
std::shared_ptr<ModelAPI_Document> Model_Session::copy(
MODEL_EXPORT virtual std::list<std::shared_ptr<ModelAPI_Document> > allOpenedDocuments();
/// Returns true if document is not loaded yet
- MODEL_EXPORT virtual bool isLoadByDemand(const std::string theDocID);
+ MODEL_EXPORT virtual bool isLoadByDemand(const std::string theDocID, const int theDocIndex);
/// Registers the plugin that creates features.
/// It is obligatory for each plugin to call this function on loading to be found by
virtual std::list<std::shared_ptr<ModelAPI_Document> > allOpenedDocuments() = 0;
/// Returns true if document is not loaded yet
- virtual bool isLoadByDemand(const std::string theDocID) = 0;
+ virtual bool isLoadByDemand(const std::string theDocID, const int theDocIndex) = 0;
/// Copies the document to the new one with the given id
virtual std::shared_ptr<ModelAPI_Document> copy(
setResult(aResult);
// do not activate part by simple execution if it is not loaded yet: it must be explicitly
// activated for this
- if (!ModelAPI_Session::get()->isLoadByDemand(aResult->data()->name())) {
+ std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef =
+ aResult->data()->document(ModelAPI_ResultPart::DOC_REF());
+ if (!ModelAPI_Session::get()->isLoadByDemand(aResult->data()->name(), aDocRef->docId())) {
// On undo/redo creation of the part result the Object Browser must get creation event
// earlier that activation of this part event (otherwise the crash is produced)
// So, send a creation event earlier, without any grouping