From dc9ef930463a86fbe979175d8c845f0cef4cccdc Mon Sep 17 00:00:00 2001 From: Ian Bassi Date: Wed, 18 Nov 2026 09:01:12 -0300 Subject: [PATCH] Don't divide by zero when hints.ini has no hints HintDatabase::init() picks a random hint with rand() % the number of loaded hints. When hints.ini is empty or can't be read, that number is zero and the app crashes at startup. get_hint() already returns nothing in that case, but only after init() has run. Ported from Snapmaker/OrcaSlicer@05acbec702c1a9e903cb30a915a8c04c021f0458 Co-authored-by: fire2wind <1229725087@qq.com> --- src/slic3r/GUI/HintNotification.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp index 2a7c9fb380..34bf6435d1 100644 --- a/src/slic3r/GUI/HintNotification.cpp +++ b/src/slic3r/GUI/HintNotification.cpp @@ -339,6 +339,10 @@ void HintDatabase::init() } void HintDatabase::init_random_hint_id() { + if (m_loaded_hints.empty()) { + m_hint_id = 0; + return; + } srand(time(NULL)); m_hint_id = rand() % m_loaded_hints.size(); }