From 895f04ccfa225c39bee1c3bb571a869de214c8c4 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Wed, 2 Sep 2026 12:00:17 -0400 Subject: [PATCH] Fix cache UI actions without UI context --- .../ui/KernelCacheUINotifications.cpp | 18 +++++++--- .../ui/SharedCacheUINotifications.cpp | 34 ++++++++++++++----- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/view/kernelcache/ui/KernelCacheUINotifications.cpp b/view/kernelcache/ui/KernelCacheUINotifications.cpp index af98c8c316..24f63ac483 100644 --- a/view/kernelcache/ui/KernelCacheUINotifications.cpp +++ b/view/kernelcache/ui/KernelCacheUINotifications.cpp @@ -108,17 +108,25 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q uint64_t addr = 0; if (GetAddressInput(addr, "Address", "Address")) { - BackgroundThread::create(ctx.context->mainWindow()) - ->thenBackground([ctx, addr]() { - loadImageAtAddr(*ctx.binaryView, addr); + auto view = ctx.binaryView; + if (!view) + return; + auto owner = ctx.context ? ctx.context->mainWindow() : nullptr; + BackgroundThread::create(owner) + ->thenBackground([view, addr]() { + loadImageAtAddr(*view, addr); })->start(); } }; auto loadImageTokenAction = [](const UIActionContext& ctx) { + auto view = ctx.binaryView; + if (!view) + return; uint64_t addr = TokenAddress(ctx); - BackgroundThread::create(ctx.context->mainWindow()) - ->thenBackground([ctx, addr](){ loadImageAtAddr(*ctx.binaryView, addr); }) + auto owner = ctx.context ? ctx.context->mainWindow() : nullptr; + BackgroundThread::create(owner) + ->thenBackground([view, addr](){ loadImageAtAddr(*view, addr); }) ->start(); }; diff --git a/view/sharedcache/ui/SharedCacheUINotifications.cpp b/view/sharedcache/ui/SharedCacheUINotifications.cpp index c67124e1d0..470fcb8164 100644 --- a/view/sharedcache/ui/SharedCacheUINotifications.cpp +++ b/view/sharedcache/ui/SharedCacheUINotifications.cpp @@ -129,9 +129,13 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q uint64_t addr = 0; if (GetAddressInput(addr, "Address", "Address")) { - BackgroundThread::create(ctx.context->mainWindow()) - ->thenBackground([ctx, addr]() { - loadImageAtAddr(*ctx.binaryView, addr); + auto view = ctx.binaryView; + if (!view) + return; + auto owner = ctx.context ? ctx.context->mainWindow() : nullptr; + BackgroundThread::create(owner) + ->thenBackground([view, addr]() { + loadImageAtAddr(*view, addr); })->start(); } }; @@ -140,23 +144,35 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q uint64_t addr = 0; if (GetAddressInput(addr, "Address", "Address")) { - BackgroundThread::create(ctx.context->mainWindow()) - ->thenBackground([ctx, addr](){ loadRegionAtAddr(*ctx.binaryView, addr); }) + auto view = ctx.binaryView; + if (!view) + return; + auto owner = ctx.context ? ctx.context->mainWindow() : nullptr; + BackgroundThread::create(owner) + ->thenBackground([view, addr](){ loadRegionAtAddr(*view, addr); }) ->start(); } }; auto loadRegionTokenAction = [](const UIActionContext& ctx) { + auto view = ctx.binaryView; + if (!view) + return; uint64_t addr = TokenAddress(ctx); - BackgroundThread::create(ctx.context->mainWindow()) - ->thenBackground([ctx, addr](){ loadRegionAtAddr(*ctx.binaryView, addr); }) + auto owner = ctx.context ? ctx.context->mainWindow() : nullptr; + BackgroundThread::create(owner) + ->thenBackground([view, addr](){ loadRegionAtAddr(*view, addr); }) ->start(); }; auto loadImageTokenAction = [](const UIActionContext& ctx) { + auto view = ctx.binaryView; + if (!view) + return; uint64_t addr = TokenAddress(ctx); - BackgroundThread::create(ctx.context->mainWindow()) - ->thenBackground([ctx, addr](){ loadImageAtAddr(*ctx.binaryView, addr); }) + auto owner = ctx.context ? ctx.context->mainWindow() : nullptr; + BackgroundThread::create(owner) + ->thenBackground([view, addr](){ loadImageAtAddr(*view, addr); }) ->start(); };