Browse Source

don't continue plan (and crash) if it fails

David Rose 15 years ago
parent
commit
c7ba043f54
2 changed files with 15 additions and 8 deletions
  1. 14 7
      direct/src/plugin/p3dPackage.cxx
  2. 1 1
      direct/src/plugin/p3dPackage.h

+ 14 - 7
direct/src/plugin/p3dPackage.cxx

@@ -138,7 +138,7 @@ activate_download() {
     // Otherwise, if we've already got the desc file, then start the
     // Otherwise, if we've already got the desc file, then start the
     // download.
     // download.
     if (_info_ready) {
     if (_info_ready) {
-      follow_install_plans(true);
+      follow_install_plans(true, false);
     }
     }
   }
   }
 }
 }
@@ -835,7 +835,7 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) {
       report_info_ready();
       report_info_ready();
     } else {
     } else {
       // We've already been authorized to start downloading, so do it.
       // We've already been authorized to start downloading, so do it.
-      follow_install_plans(true);
+      follow_install_plans(true, false);
     }
     }
   }
   }
 }
 }
@@ -979,12 +979,17 @@ build_install_plans(TiXmlDocument *doc) {
 //     Function: P3DPackage::follow_install_plans
 //     Function: P3DPackage::follow_install_plans
 //       Access: Private
 //       Access: Private
 //  Description: Performs the next step in the current install plan.
 //  Description: Performs the next step in the current install plan.
+//
 //               If download_finished is false, there is a pending
 //               If download_finished is false, there is a pending
 //               download that has not fully completed yet; otherwise,
 //               download that has not fully completed yet; otherwise,
 //               download_finished should be set true.
 //               download_finished should be set true.
+//
+//               If plan_failed is false, it means that the
+//               top-of-stack plan is still good; if true, the
+//               top-of-stack plan has failed and should be removed.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void P3DPackage::
 void P3DPackage::
-follow_install_plans(bool download_finished) {
+follow_install_plans(bool download_finished, bool plan_failed) {
   if (!_allow_data_download || _failed) {
   if (!_allow_data_download || _failed) {
     // Not authorized yet, or something went wrong.
     // Not authorized yet, or something went wrong.
     return;
     return;
@@ -994,7 +999,6 @@ follow_install_plans(bool download_finished) {
     // Pull the next step off the current plan.
     // Pull the next step off the current plan.
 
 
     InstallPlan &plan = _install_plans.front();
     InstallPlan &plan = _install_plans.front();
-    bool plan_failed = false;
 
 
     if (!_computed_plan_size) {
     if (!_computed_plan_size) {
       _total_plan_size = 0.0;
       _total_plan_size = 0.0;
@@ -1062,6 +1066,9 @@ follow_install_plans(bool download_finished) {
     nout << "Plan failed.\n";
     nout << "Plan failed.\n";
     _install_plans.pop_front();
     _install_plans.pop_front();
     _computed_plan_size = false;
     _computed_plan_size = false;
+
+    // The next plan is (so far as we know) still good.
+    plan_failed = false;
   }
   }
 
 
   // All plans failed.  Too bad for us.
   // All plans failed.  Too bad for us.
@@ -1077,7 +1084,7 @@ follow_install_plans(bool download_finished) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void P3DPackage::
 void P3DPackage::
 st_callback(void *self) {
 st_callback(void *self) {
-  ((P3DPackage *)self)->follow_install_plans(false);
+  ((P3DPackage *)self)->follow_install_plans(false, false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1397,7 +1404,7 @@ download_progress() {
     break;
     break;
 
 
   case DT_install_step:
   case DT_install_step:
-    _package->follow_install_plans(false);
+    _package->follow_install_plans(false, false);
     break;
     break;
   }
   }
 }
 }
@@ -1493,7 +1500,7 @@ resume_download_finished(bool success) {
     break;
     break;
 
 
   case DT_install_step:
   case DT_install_step:
-    _package->follow_install_plans(true);
+    _package->follow_install_plans(true, !success);
     break;
     break;
   }
   }
 }
 }

+ 1 - 1
direct/src/plugin/p3dPackage.h

@@ -225,7 +225,7 @@ private:
 
 
   void clear_install_plans();
   void clear_install_plans();
   void build_install_plans(TiXmlDocument *doc);
   void build_install_plans(TiXmlDocument *doc);
-  void follow_install_plans(bool download_finished);
+  void follow_install_plans(bool download_finished, bool plan_failed);
   static void st_callback(void *self);
   static void st_callback(void *self);
   void request_callback();
   void request_callback();