summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/services/schemes.ts3
-rw-r--r--src/utils/system.ts5
2 files changed, 6 insertions, 2 deletions
diff --git a/src/services/schemes.ts b/src/services/schemes.ts
index 548975c..2808b55 100644
--- a/src/services/schemes.ts
+++ b/src/services/schemes.ts
@@ -32,7 +32,6 @@ export default class Schemes extends GObject.Object {
}
readonly #schemeDir: string = `${DATA}/scripts/data/schemes`;
- readonly #monitor;
#map: { [k: string]: Scheme } = {};
@@ -106,7 +105,7 @@ export default class Schemes extends GObject.Object {
super();
this.update().catch(console.error);
- this.#monitor = monitorDirectory(this.#schemeDir, (_m, file, _f, type) => {
+ monitorDirectory(this.#schemeDir, (_m, file, _f, type) => {
if (type !== Gio.FileMonitorEvent.DELETED) this.updateFile(file).catch(console.error);
});
}
diff --git a/src/utils/system.ts b/src/utils/system.ts
index 2e9fa4a..8ccb5d1 100644
--- a/src/utils/system.ts
+++ b/src/utils/system.ts
@@ -76,6 +76,7 @@ export const bindCurrentTime = (
return bind(time);
};
+const monitors = new Set();
export const monitorDirectory = (
path: string,
callback: (
@@ -102,5 +103,9 @@ export const monitorDirectory = (
}
}
+ // Keep ref to monitor so it doesn't get GCed
+ monitors.add(monitor);
+ monitor.connect("notify::cancelled", () => monitor.cancelled && monitors.delete(monitor));
+
return monitor;
};