Skip to content

Commit 727e0e3

Browse files
authored
Events should not be added to queue if event loop is not started. (#8640)
1 parent 852816a commit 727e0e3

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

common/api/core-frontend.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4941,6 +4941,8 @@ export class IModelApp {
49414941
static get hasRenderSystem(): boolean;
49424942
static get hubAccess(): FrontendHubAccess | undefined;
49434943
static get initialized(): boolean;
4944+
// @internal
4945+
static get isEventLoopStarted(): boolean;
49444946
static get localization(): Localization;
49454947
// (undocumented)
49464948
static get locateManager(): ElementLocateManager;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/core-frontend",
5+
"comment": "",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@itwin/core-frontend"
10+
}

core/frontend/src/IModelApp.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ export class IModelApp {
525525
}, IModelApp.animationInterval.milliseconds);
526526
}
527527

528+
/** Return true if the main event processing loop has been started.
529+
* @internal
530+
*/
531+
public static get isEventLoopStarted() { return IModelApp._wantEventLoop; }
532+
528533
/** @internal */
529534
public static startEventLoop() {
530535
if (!IModelApp._wantEventLoop) {

core/frontend/src/tools/ToolAdmin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,10 @@ export class ToolAdmin {
790790
* @internal
791791
*/
792792
public static addEvent(ev: Event, vp?: ScreenViewport): void {
793+
// Don't add events to queue if event loop hasn't been started to process them...
794+
if (!IModelApp.isEventLoopStarted)
795+
return;
796+
793797
if (!ToolAdmin.tryReplace(ev, vp)) // see if this event replaces the last event in the queue
794798
this._toolEvents.push({ ev, vp }); // otherwise put it at the end of the queue.
795799

0 commit comments

Comments
 (0)