Skip to content

Commit b3e6524

Browse files
committed
linux: fix crash on tray Open/Settings and add Fusion style fallback
- Fix segfault when calling .first() on empty rootObjects() or topLevelWindows() lists in tray menu handlers - Add Fusion as fallback Qt Quick Controls style to prevent QML load failures when platform theme modules (e.g., kvantum) are not installed - Override QT_STYLE_OVERRIDE=kvantum to Fusion before QApplication init The Fusion style is built into Qt and available on all platforms (X11, Wayland, KDE, GNOME, etc.), ensuring the app works regardless of the user's theme configuration.
1 parent d3b60cc commit b3e6524

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

linux/main.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ int main(int argc, char *argv[]) {
11711171

11721172
QObject::connect(&server, &QLocalServer::newConnection, [&]() {
11731173
QLocalSocket* socket = server.nextPendingConnection();
1174+
QObject::connect(socket, &QLocalSocket::disconnected, socket, &QLocalSocket::deleteLater);
11741175

11751176
QObject::connect(socket, &QLocalSocket::readyRead, [socket, &engine, trayApp]() {
11761177
QString msg = QString::fromUtf8(socket->readAll());
@@ -1191,8 +1192,11 @@ int main(int argc, char *argv[]) {
11911192
}
11921193
else if (msg.startsWith("cli:set-noise-mode:")) {
11931194
QString modeStr = msg.mid(QString("cli:set-noise-mode:").length());
1194-
int mode = modeStr.toInt();
1195-
if (!trayApp->areAirpodsConnected()) {
1195+
bool ok;
1196+
int mode = modeStr.toInt(&ok);
1197+
if (!ok || mode < 0 || mode > 3) {
1198+
response = "Error: Invalid noise mode";
1199+
} else if (!trayApp->areAirpodsConnected()) {
11961200
response = "Error: AirPods not connected";
11971201
} else {
11981202
trayApp->setNoiseControlModeInt(mode);
@@ -1201,18 +1205,22 @@ int main(int argc, char *argv[]) {
12011205
}
12021206
else if (msg.startsWith("cli:set-ca:")) {
12031207
QString stateStr = msg.mid(QString("cli:set-ca:").length());
1204-
bool enabled = (stateStr == "1");
1205-
if (!trayApp->areAirpodsConnected()) {
1208+
if (stateStr != "0" && stateStr != "1") {
1209+
response = "Error: Invalid state";
1210+
} else if (!trayApp->areAirpodsConnected()) {
12061211
response = "Error: AirPods not connected";
12071212
} else {
1208-
trayApp->setConversationalAwareness(enabled);
1213+
trayApp->setConversationalAwareness(stateStr == "1");
12091214
response = "OK";
12101215
}
12111216
}
12121217
else if (msg.startsWith("cli:set-adaptive-level:")) {
12131218
QString levelStr = msg.mid(QString("cli:set-adaptive-level:").length());
1214-
int level = levelStr.toInt();
1215-
if (!trayApp->areAirpodsConnected()) {
1219+
bool ok;
1220+
int level = levelStr.toInt(&ok);
1221+
if (!ok || level < 0 || level > 100) {
1222+
response = "Error: Invalid level (0-100)";
1223+
} else if (!trayApp->areAirpodsConnected()) {
12161224
response = "Error: AirPods not connected";
12171225
} else {
12181226
trayApp->setAdaptiveNoiseLevel(level);

0 commit comments

Comments
 (0)