Skip to content

Commit 0895d45

Browse files
committed
Fix Typography app crash on resizing
1 parent b7143c9 commit 0895d45

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Apps/05-Typography/TypographyApp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ bool TypographyApp::Resize(const gfx::FrameSize& frame_size, bool is_minimized)
308308
if (!UserInterfaceApp::Resize(frame_size, is_minimized))
309309
return false;
310310

311+
// Text items and font atlas badges are created by Init() only after the base application was
312+
// initialized, so a resize event received in between (for example, when Init() was interrupted
313+
// by an exception) has nothing to lay out yet and must not index the incomplete text items.
314+
if (m_texts.size() < g_text_blocks_count)
315+
return false;
316+
311317
const gfx::FrameSize frame_size_in_dots = GetFrameSizeInDots();
312318
int32_t vertical_text_pos_in_dots = g_top_text_pos_in_dots;
313319

Modules/Platform/App/Sources/Methane/Platform/AppBase.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ bool AppBase::Resize(const Data::FrameSize& frame_size, bool is_minimized)
242242
m_frame_size = frame_size;
243243
}
244244

245-
return m_initialized && is_resizing;
245+
// Resizing is stopped after an error the same way as rendering is stopped in UpdateAndRender():
246+
// Init() sets m_initialized before the derived application has finished its own initialization,
247+
// so an Init() interrupted by an exception leaves partially constructed application state, which
248+
// the platform apps would otherwise keep resizing until the error alert terminates the process.
249+
return m_initialized && is_resizing && !HasError();
246250
}
247251

248252
void AppBase::Alert(const Message& msg, bool deferred)

0 commit comments

Comments
 (0)