Skip to content

Commit e7dcd53

Browse files
committed
Fix cache UI actions without UI context
1 parent 651791b commit e7dcd53

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

‎view/kernelcache/ui/KernelCacheUINotifications.cpp‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,25 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q
108108
uint64_t addr = 0;
109109
if (GetAddressInput(addr, "Address", "Address"))
110110
{
111-
BackgroundThread::create(ctx.context->mainWindow())
112-
->thenBackground([ctx, addr]() {
113-
loadImageAtAddr(*ctx.binaryView, addr);
111+
auto view = ctx.binaryView;
112+
if (!view)
113+
return;
114+
auto owner = ctx.context ? ctx.context->mainWindow() : nullptr;
115+
BackgroundThread::create(owner)
116+
->thenBackground([view, addr]() {
117+
loadImageAtAddr(*view, addr);
114118
})->start();
115119
}
116120
};
117121

118122
auto loadImageTokenAction = [](const UIActionContext& ctx) {
123+
auto view = ctx.binaryView;
124+
if (!view)
125+
return;
119126
uint64_t addr = TokenAddress(ctx);
120-
BackgroundThread::create(ctx.context->mainWindow())
121-
->thenBackground([ctx, addr](){ loadImageAtAddr(*ctx.binaryView, addr); })
127+
auto owner = ctx.context ? ctx.context->mainWindow() : nullptr;
128+
BackgroundThread::create(owner)
129+
->thenBackground([view, addr](){ loadImageAtAddr(*view, addr); })
122130
->start();
123131
};
124132

‎view/sharedcache/ui/SharedCacheUINotifications.cpp‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q
129129
uint64_t addr = 0;
130130
if (GetAddressInput(addr, "Address", "Address"))
131131
{
132-
BackgroundThread::create(ctx.context->mainWindow())
133-
->thenBackground([ctx, addr]() {
134-
loadImageAtAddr(*ctx.binaryView, addr);
132+
auto view = ctx.binaryView;
133+
if (!view)
134+
return;
135+
auto owner = ctx.context ? ctx.context->mainWindow() : nullptr;
136+
BackgroundThread::create(owner)
137+
->thenBackground([view, addr]() {
138+
loadImageAtAddr(*view, addr);
135139
})->start();
136140
}
137141
};
@@ -140,23 +144,35 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q
140144
uint64_t addr = 0;
141145
if (GetAddressInput(addr, "Address", "Address"))
142146
{
143-
BackgroundThread::create(ctx.context->mainWindow())
144-
->thenBackground([ctx, addr](){ loadRegionAtAddr(*ctx.binaryView, addr); })
147+
auto view = ctx.binaryView;
148+
if (!view)
149+
return;
150+
auto owner = ctx.context ? ctx.context->mainWindow() : nullptr;
151+
BackgroundThread::create(owner)
152+
->thenBackground([view, addr](){ loadRegionAtAddr(*view, addr); })
145153
->start();
146154
}
147155
};
148156

149157
auto loadRegionTokenAction = [](const UIActionContext& ctx) {
158+
auto view = ctx.binaryView;
159+
if (!view)
160+
return;
150161
uint64_t addr = TokenAddress(ctx);
151-
BackgroundThread::create(ctx.context->mainWindow())
152-
->thenBackground([ctx, addr](){ loadRegionAtAddr(*ctx.binaryView, addr); })
162+
auto owner = ctx.context ? ctx.context->mainWindow() : nullptr;
163+
BackgroundThread::create(owner)
164+
->thenBackground([view, addr](){ loadRegionAtAddr(*view, addr); })
153165
->start();
154166
};
155167

156168
auto loadImageTokenAction = [](const UIActionContext& ctx) {
169+
auto view = ctx.binaryView;
170+
if (!view)
171+
return;
157172
uint64_t addr = TokenAddress(ctx);
158-
BackgroundThread::create(ctx.context->mainWindow())
159-
->thenBackground([ctx, addr](){ loadImageAtAddr(*ctx.binaryView, addr); })
173+
auto owner = ctx.context ? ctx.context->mainWindow() : nullptr;
174+
BackgroundThread::create(owner)
175+
->thenBackground([view, addr](){ loadImageAtAddr(*view, addr); })
160176
->start();
161177
};
162178

0 commit comments

Comments
 (0)