mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-02 09:48:14 -05:00
Do not prebuild pages while a modal dialog is open (#16994)
On macOS the app could hang at 100% CPU when a project with customized presets was opened into a running app and the message box was closed while the idle prebuild was building the Project page's web view. The web view waits for WebKit in a wxYield() loop, and closing the dialog aborts the modal session, so the reply never arrives. The idle scheduler now runs a slice only in the main event loop, so no pages are built while a modal dialog is open. Building resumes when the dialog closes.
This commit is contained in:
1 parent
6112429980
commit
3610d8bb35
1 file changed
+6
-4
@@ -45,11 +45,13 @@ bool input_pending()
|
||||
#endif
|
||||
}
|
||||
|
||||
// True inside a wxYield(), where a slice would build pages in the middle of the code that yielded.
|
||||
bool yielding()
|
||||
// True inside a wxYield() or a nested loop such as a modal dialog's, where a slice would build pages in
|
||||
// the middle of the code that is waiting. A new web view waits for WebKit in a yield loop; if the dialog
|
||||
// closes meanwhile, macOS aborts its modal session, the reply never arrives and the app hangs.
|
||||
bool in_nested_loop()
|
||||
{
|
||||
const wxEventLoopBase* loop = wxEventLoopBase::GetActive();
|
||||
return loop != nullptr && loop->IsYielding();
|
||||
return loop != nullptr && (loop->IsYielding() || !loop->IsMain());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -79,7 +81,7 @@ void IdleScheduler::tick()
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
if (m_input_idle_ms() < quiet_ms || input_pending() || yielding()) {
|
||||
if (m_input_idle_ms() < quiet_ms || input_pending() || in_nested_loop()) {
|
||||
start();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user