diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index cb802e9c96..08a4b37c32 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -1495,8 +1495,17 @@ auth_finished_main_thread() { // normally called by JavaScript, via // P3DMainObject::call_uninstall(). //////////////////////////////////////////////////////////////////// -void P3DInstance:: +bool P3DInstance:: uninstall_packages() { + if (_packages.empty()) { + // If we have no packages (for instance, because we're untrusted), + // we can't uninstall anything. + nout << "Uninstall failed: no packages.\n"; + return false; + } + + nout << "Uninstalling " << _packages.size() << " packages\n"; + Packages::const_iterator pi; for (pi = _packages.begin(); pi != _packages.end(); ++pi) { P3DPackage *package = (*pi); @@ -1514,6 +1523,8 @@ uninstall_packages() { nout << "Cleaning up start directory " << start_dir << "\n"; inst_mgr->delete_directory_recursively(start_dir); } + + return true; } //////////////////////////////////////////////////////////////////// @@ -1526,8 +1537,15 @@ uninstall_packages() { // is normally called by JavaScript, via // P3DMainObject::call_uninstall(). //////////////////////////////////////////////////////////////////// -void P3DInstance:: +bool P3DInstance:: uninstall_host() { + if (_packages.empty()) { + // If we have no packages (for instance, because we're untrusted), + // we can't uninstall anything. + nout << "Uninstall failed: no packages.\n"; + return false; + } + uninstall_packages(); // Collect the set of hosts referenced by this instance. @@ -1540,6 +1558,7 @@ uninstall_host() { hosts.insert(package->get_host()); } } + nout << "Uninstalling " << hosts.size() << " hosts\n"; // Uninstall all of them. set::iterator hi; @@ -1547,6 +1566,8 @@ uninstall_host() { P3DHost *host = (*hi); host->uninstall(); } + + return true; } //////////////////////////////////////////////////////////////////// diff --git a/direct/src/plugin/p3dInstance.h b/direct/src/plugin/p3dInstance.h index 26bd28c777..c8239e47f6 100644 --- a/direct/src/plugin/p3dInstance.h +++ b/direct/src/plugin/p3dInstance.h @@ -119,8 +119,8 @@ public: void auth_finished_sub_thread(); void auth_finished_main_thread(); - void uninstall_packages(); - void uninstall_host(); + bool uninstall_packages(); + bool uninstall_host(); private: class ImageDownload : public P3DFileDownload { diff --git a/direct/src/plugin/p3dMainObject.cxx b/direct/src/plugin/p3dMainObject.cxx index b10375809a..6cd4a7fd9e 100644 --- a/direct/src/plugin/p3dMainObject.cxx +++ b/direct/src/plugin/p3dMainObject.cxx @@ -709,12 +709,13 @@ call_uninstall(P3D_object *params[], int num_params) { if (_inst != NULL) { nout << "uninstall " << mode << " for " << _inst << "\n"; + bool success = false; if (mode == "host") { - _inst->uninstall_host(); + success = _inst->uninstall_host(); } else { - _inst->uninstall_packages(); + success = _inst->uninstall_packages(); } - return inst_mgr->new_bool_object(true); + return inst_mgr->new_bool_object(success); } nout << "couldn't uninstall; no instance.\n";