Fix: Initialization and Error Handling for Libnotify (#2659)

* fix libnotify
* Add notification error handling
This commit is contained in:
JC-comp 2024-03-10 08:18:54 +08:00 committed by GitHub
parent fda043061a
commit 3d249b8d10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

@ -99,8 +99,13 @@ class LogBuffer {
shared void notify(string message) {
// Use dnotify's functionality for GUI notifications, if GUI notifications is enabled
version(Notifications) {
auto n = new Notification("Log Notification", message, "IGNORED");
n.show();
try {
auto n = new Notification("Log Notification", message, "IGNORED");
n.show();
} catch (NotificationError e) {
sendGUINotification = false;
addLogEntry("Unable to send notification; disabled in the following: " ~ e.message);
}
}
}

View file

@ -79,11 +79,11 @@ void init(in char[] name) {
alias notify_is_initted is_initted;
alias notify_uninit uninit;
static this() {
shared static this() {
init(__FILE__);
}
static ~this() {
shared static ~this() {
uninit();
}