Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit e46e53a

Browse files
committed
[[ Bug 22705 ]] Resolve crash focusing on unopen stack
This patch resolves a crash where `controlgainedfocus` is called with a stack parameter which is unopened and therefore `p_stack -> getwindow()` returns `nullptr`.
1 parent b527ae8 commit e46e53a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/notes/bugfix-22705.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix crash focusing on an unopen stack

engine/src/desktop-dc.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,11 @@ MCImageBitmap *MCScreenDC::snapshot(MCRectangle &p_rect, uint4 p_window, MCStrin
11141114

11151115
void MCScreenDC::controlgainedfocus(MCStack *p_stack, uint32_t p_id)
11161116
{
1117-
MCPlatformSwitchFocusToView(p_stack -> getwindow(), p_id);
1117+
MCPlatformWindowRef t_window = p_stack -> getwindow();
1118+
if (t_window != nullptr)
1119+
{
1120+
MCPlatformSwitchFocusToView(p_stack -> getwindow(), p_id);
1121+
}
11181122
}
11191123

11201124
void MCScreenDC::controllostfocus(MCStack *p_stack, uint32_t p_id)

0 commit comments

Comments
 (0)