Skip to content

Commit 3c3610c

Browse files
committed
Clear timers on quit
1 parent 37918cb commit 3c3610c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ function shutdownApplication() {
135135
console.log('Initiating application shutdown...');
136136

137137
try {
138+
// Signal renderer to clear timers
139+
if (s_mainWindow && !s_mainWindow.isDestroyed()) {
140+
console.log('Sending cleanup signal to renderer...');
141+
s_mainWindow.webContents.send('cleanup');
142+
}
143+
138144
// Close all servers
139145
if (WServer) {
140146
console.log('Closing UDP server...');

renderer.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
let cfg={};
1111
let active_cfg=0;
1212
let trxpoll=undefined;
13+
let utcTimeInterval=undefined;
1314

1415
const {ipcRenderer} = require('electron')
1516
const net = require('net');
@@ -81,6 +82,7 @@ $(document).ready(function() {
8182
});
8283

8384
bt_quit.addEventListener('click', () => {
85+
cleanupTimers(); // Clear all timers before quit
8486
const x=ipcRenderer.sendSync("quit", '');
8587
});
8688

@@ -115,7 +117,7 @@ $(document).ready(function() {
115117
getStations();
116118
});
117119

118-
setInterval(updateUtcTime, 1000);
120+
utcTimeInterval = setInterval(updateUtcTime, 1000);
119121
window.onload = updateUtcTime;
120122

121123
$("#config-tab").on("click",function() {
@@ -139,6 +141,11 @@ $(document).ready(function() {
139141
ipcRenderer.send('get_info_result', result);
140142
});
141143

144+
// Handle cleanup request from main process
145+
ipcRenderer.on('cleanup', () => {
146+
cleanupTimers();
147+
});
148+
142149
// Dropdown change handler
143150
$('#radio_type').change(function() {
144151
updateRadioFields();
@@ -396,6 +403,22 @@ async function informWavelog(CAT) {
396403
return x;
397404
}
398405

406+
function cleanupTimers() {
407+
// Clear radio polling timeout
408+
if (trxpoll) {
409+
clearTimeout(trxpoll);
410+
trxpoll = undefined;
411+
console.log('Cleared radio polling timeout');
412+
}
413+
414+
// Clear UTC time update interval
415+
if (utcTimeInterval) {
416+
clearInterval(utcTimeInterval);
417+
utcTimeInterval = undefined;
418+
console.log('Cleared UTC time update interval');
419+
}
420+
}
421+
399422
function updateUtcTime() {
400423
const now = new Date();
401424

0 commit comments

Comments
 (0)