Skip to content

Commit 03eb1b3

Browse files
Alberto Iannacconefstasi
Alberto Iannaccone
authored andcommitted
clear flush message interval when disconnecting
1 parent f333bbd commit 03eb1b3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Diff for: arduino-ide-extension/src/electron-main/theia/electron-main-application.ts

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
101101
minWidth: 620,
102102
height: 500,
103103
minHeight: 320,
104-
center: true,
105104
x: 100,
106105
y: 100,
107106
webPreferences: {

Diff for: arduino-ide-extension/src/node/monitor/monitor-service-impl.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export class MonitorServiceImpl implements MonitorService {
7777
config: MonitorConfig;
7878
};
7979
protected messages: string[] = [];
80-
protected onMessageReceived: Disposable;
80+
protected onMessageReceived: Disposable | null;
81+
protected flushMessagesInterval: NodeJS.Timeout | null;
8182

8283
setClient(client: MonitorServiceClient | undefined): void {
8384
this.client = client;
@@ -180,7 +181,7 @@ export class MonitorServiceImpl implements MonitorService {
180181
);
181182

182183
// empty the queue every 32ms (~30fps)
183-
setInterval(flushMessagesToFrontend, 32);
184+
this.flushMessagesInterval = setInterval(flushMessagesToFrontend, 32);
184185

185186
// converts 'ab\nc\nd' => [ab\n,c\n,d]
186187
const stringToArray = (string: string, separator = '\n') => {
@@ -247,7 +248,15 @@ export class MonitorServiceImpl implements MonitorService {
247248

248249
async disconnect(reason?: MonitorError): Promise<Status> {
249250
try {
250-
this.onMessageReceived.dispose();
251+
if (this.onMessageReceived) {
252+
this.onMessageReceived.dispose();
253+
this.onMessageReceived = null;
254+
}
255+
if (this.flushMessagesInterval) {
256+
clearInterval(this.flushMessagesInterval);
257+
this.flushMessagesInterval = null;
258+
}
259+
251260
if (
252261
!this.serialConnection &&
253262
reason &&

0 commit comments

Comments
 (0)