From 8a36164625aa07f389222898b33dbe6da0db635e Mon Sep 17 00:00:00 2001
From: extracold1209 <extracold1209@gmail.com>
Date: Wed, 3 Apr 2019 12:22:29 +0900
Subject: [PATCH] =?UTF-8?q?[!]=20Electron=20Close=20=EC=8B=9C=20error=20/?=
 =?UTF-8?q?=20=EA=B3=84=EC=86=8D=20checkInitialData=20=EC=A7=84=ED=96=89?=
 =?UTF-8?q?=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- Electron Close 찰나에 WebContents 오브젝트 사용하여 발생한 에러 수정
- serialPort 를 source 로 바꿨음에도 sp 의 이벤트만 삭제해서 발생한 에러
  수정
---
 app/custom_modules/router/scanner/serial.js | 1 +
 app/index.js                                | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/custom_modules/router/scanner/serial.js b/app/custom_modules/router/scanner/serial.js
index e05878155..a4b899ed8 100644
--- a/app/custom_modules/router/scanner/serial.js
+++ b/app/custom_modules/router/scanner/serial.js
@@ -194,6 +194,7 @@ Scanner.prototype.scan = function (serialport, extension, config, callback) {
 
 											var result = extension.checkInitialData(data, config);
 											if (result !== undefined) {
+												source.removeAllListeners('data');
 												sp.removeAllListeners('data');
 												clearTimeout(flashFirmware);
 												if (result === true) {
diff --git a/app/index.js b/app/index.js
index d7b75dab1..744fe6b99 100644
--- a/app/index.js
+++ b/app/index.js
@@ -321,7 +321,9 @@ if (!app.requestSingleInstanceLock()) {
     let requestLocalDataInterval = -1;
     ipcMain.on('startRequestLocalData', function(event, duration) {
         requestLocalDataInterval = setInterval(() => {
-            event.sender.send('sendingRequestLocalData');
+            if (!event.sender.isDestroyed()) {
+                event.sender.send('sendingRequestLocalData');
+            }
         }, duration);
     });
     ipcMain.on('stopRequestLocalData', function() {