| 295 | } |
| 296 | |
| 297 | void |
| 298 | BundlePrivate::Uninstall() |
| 299 | { |
| 300 | { |
| 301 | auto l = this->Lock(); |
| 302 | US_UNUSED(l); |
| 303 | |
| 304 | switch (static_cast<Bundle::State>(state.load())) |
| 305 | { |
| 306 | case Bundle::STATE_UNINSTALLED: |
| 307 | throw std::logic_error("Bundle " + symbolicName + " (location=" + location |
| 308 | + ") is in BUNDLE_UNINSTALLED state"); |
| 309 | case Bundle::STATE_STARTING: // Lazy start |
| 310 | case Bundle::STATE_ACTIVE: |
| 311 | case Bundle::STATE_STOPPING: |
| 312 | { |
| 313 | std::exception_ptr exception; |
| 314 | try |
| 315 | { |
| 316 | exception = (state & (Bundle::STATE_ACTIVE | Bundle::STATE_STARTING)) != 0 ? Stop0() : nullptr; |
| 317 | } |
| 318 | catch (...) |
| 319 | { |
| 320 | // Force to install |
| 321 | SetStateInstalled(false); |
| 322 | exception = std::current_exception(); |
| 323 | } |
| 324 | operation = BundlePrivate::OP_UNINSTALLING; |
| 325 | if (exception != nullptr) |
| 326 | { |
| 327 | try |
| 328 | { |
| 329 | std::rethrow_exception(exception); |
| 330 | } |
| 331 | catch (...) |
| 332 | { |
| 333 | coreCtx->listeners.SendFrameworkEvent(FrameworkEvent(FrameworkEvent::Type::FRAMEWORK_ERROR, |
| 334 | MakeBundle(shared_from_this()), |
| 335 | std::string(), |
| 336 | std::current_exception())); |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | [[fallthrough]]; |
| 341 | case Bundle::STATE_RESOLVED: |
| 342 | case Bundle::STATE_INSTALLED: |
| 343 | { |
| 344 | coreCtx->bundleRegistry.Remove(location, id); |
| 345 | if (operation != BundlePrivate::OP_UNINSTALLING) |
| 346 | { |
| 347 | try |
| 348 | { |
| 349 | operation = BundlePrivate::OP_UNINSTALLING; |
| 350 | } |
| 351 | catch (...) |
| 352 | { |
| 353 | // Make sure that bundleContext is invalid |
| 354 | std::shared_ptr<BundleContextPrivate> ctx; |
nothing calls this directly
no test coverage detected