@@ -436,13 +436,19 @@ void CesiumIonSessionImpl::refreshProfile(
436436 .thenInMainThread (
437437 [this , session](
438438 CesiumIonClient::Response<CesiumIonClient::Profile>&& profile) {
439+ if (session == nullptr )
440+ return ;
441+
439442 this ->_isLoadingProfile = false ;
440443 this ->_profile = std::move (profile.value );
441444 this ->broadcastProfileUpdate ();
442445 if (this ->_loadProfileQueued )
443446 this ->refreshProfile (session);
444447 })
445448 .catchInMainThread ([this , session](std::exception&& e) {
449+ if (session == nullptr )
450+ return ;
451+
446452 this ->_isLoadingProfile = false ;
447453 this ->_profile = std::nullopt ;
448454 this ->broadcastProfileUpdate ();
@@ -470,13 +476,19 @@ void CesiumIonSessionImpl::refreshAssets(
470476 .thenInMainThread (
471477 [this , session](
472478 CesiumIonClient::Response<CesiumIonClient::Assets>&& assets) {
479+ if (session == nullptr )
480+ return ;
481+
473482 this ->_isLoadingAssets = false ;
474483 this ->_assets = std::move (assets.value );
475484 this ->broadcastAssetsUpdate ();
476485 if (this ->_loadAssetsQueued )
477486 this ->refreshAssets (session);
478487 })
479488 .catchInMainThread ([this , session](std::exception&& e) {
489+ if (session == nullptr )
490+ return ;
491+
480492 this ->_isLoadingAssets = false ;
481493 this ->_assets = std::nullopt ;
482494 this ->broadcastAssetsUpdate ();
@@ -509,6 +521,9 @@ void CesiumIonSessionImpl::refreshTokens(
509521 .thenInMainThread (
510522 [this , session](
511523 CesiumIonClient::Response<CesiumIonClient::TokenList>&& tokens) {
524+ if (session == nullptr )
525+ return ;
526+
512527 this ->_isLoadingTokens = false ;
513528 this ->_tokens =
514529 tokens.value
@@ -519,6 +534,9 @@ void CesiumIonSessionImpl::refreshTokens(
519534 this ->refreshTokens (session);
520535 })
521536 .catchInMainThread ([this , session](std::exception&& e) {
537+ if (session == nullptr )
538+ return ;
539+
522540 this ->_isLoadingTokens = false ;
523541 this ->_tokens = std::nullopt ;
524542 this ->broadcastTokensUpdate ();
@@ -541,6 +559,9 @@ void CesiumIonSessionImpl::refreshDefaults(
541559 .thenInMainThread (
542560 [this , session](
543561 CesiumIonClient::Response<CesiumIonClient::Defaults>&& defaults) {
562+ if (session == nullptr )
563+ return ;
564+
544565 logResponseErrors (defaults);
545566 this ->_isLoadingDefaults = false ;
546567 this ->_defaults = std::move (defaults.value );
@@ -550,6 +571,9 @@ void CesiumIonSessionImpl::refreshDefaults(
550571 this ->refreshDefaults (session);
551572 })
552573 .catchInMainThread ([this , session](std::exception&& e) {
574+ if (session == nullptr )
575+ return ;
576+
553577 logResponseErrors (e);
554578 this ->_isLoadingDefaults = false ;
555579 this ->_defaults = std::nullopt ;
0 commit comments