mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-01 09:22:58 -05:00
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@05acbec702 Co-authored-by: fire2wind <1229725087@qq.com>
This commit is contained in:
1 parent
abe2fba75c
commit
dc9ef93046
1 file changed
+4
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user