]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMMain.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMMain.cpp
index 25331dc7c1d1403dda1ee3cddbf04ad81a348438..b3c381ff12064be15f6dd7a4661a4a4b3c8819f1 100644 (file)
@@ -133,6 +133,11 @@ bool modelCDMMain::CreateProject(
   //std::cout << "executing " << add << std::endl;
   system(add.c_str());
 
+  if(this->project != NULL)
+    {
+      if (!CloseProject(result))
+        return false;
+    }
 
   this->project = new modelCDMProject(nomDirectory);
 
@@ -216,6 +221,12 @@ bool modelCDMMain::OpenProject(
   //if is source folder
   if(isSource)
     {
+      if(this->project != NULL)
+        {
+          if (!CloseProject(result))
+            return false;
+        }
+
       std::cout << "Project sources at: " << pathSource << std::endl;
       if(isBinary)
         {
@@ -240,14 +251,32 @@ bool modelCDMMain::RefreshProject(
     std::string*& result
 )
 {
-  //TODO: recreate the project using the project's path
-  return true;
+  //recreate the project using the project's path
+  if (this->project != NULL)
+    {
+      return this->project->Refresh(result);
+    }
+  else
+    {
+      result = new std::string("There is no open project.");
+      return false;
+    }
 }
 
 bool modelCDMMain::CloseProject(
     std::string*& result
 )
 {
-  //TODO: delete the project tree and leave it as NULL
-  return true;
+  //delete the project tree and leave it as NULL
+  if (this->project != NULL)
+    {
+      delete this->project;
+      this->project = NULL;
+      return true;
+    }
+  else
+    {
+      result = new std::string("There is no open project.");
+      return false;
+    }
 }