浏览代码

fix(electron): Detach all file watcher listeners when force quit app if not App will not response and crash

charlie 4 年之前
父节点
当前提交
361e84bbbb
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/electron/electron/handler.cljs

+ 4 - 1
src/electron/electron/handler.cljs

@@ -1,5 +1,5 @@
 (ns electron.handler
-  (:require ["electron" :refer [ipcMain dialog]]
+  (:require ["electron" :refer [ipcMain dialog app]]
             [cljs-bean.core :as bean]
             ["fs" :as fs]
             ["path" :as path]
@@ -107,6 +107,9 @@
          (fn [path]
            (println "Watch error happend: "
                     {:path path})))
+
+    (.on app "quit" #(.close watcher))
+
     true))
 
 (defmethod handle :addDirWatcher [window [_ dir]]