Improve D-Bus processing on macOS
Unset launchctl env before running the new one, to avoid connecting through the old launchctl env. Show a warn message for D-Bus connection failure on macOS.
This commit is contained in:
parent
cb7a9203dd
commit
19d0b8f4bc
1 changed files with 12 additions and 1 deletions
|
@ -84,6 +84,7 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd)
|
|||
// Here we will try to bring our private session D-Bus
|
||||
if (!hasUsableSessionBus) {
|
||||
qDebug() << "Launching private session D-Bus.";
|
||||
DBusHelper::macosUnsetLaunchctlEnv();
|
||||
DBusHelper::launchDBusDaemon();
|
||||
// Wait for dbus daemon env
|
||||
QProcess getLaunchdDBusEnv;
|
||||
|
@ -99,9 +100,19 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd)
|
|||
|
||||
QString launchdDBusEnv = QString::fromLocal8Bit(getLaunchdDBusEnv.readAllStandardOutput());
|
||||
|
||||
if (launchdDBusEnv.length() > 0 && QDBusConnection::sessionBus().isConnected()) {
|
||||
if (!launchdDBusEnv.isEmpty() && QDBusConnection::sessionBus().isConnected()) {
|
||||
qDebug() << "Private D-Bus daemon launched and connected.";
|
||||
hasUsableSessionBus = true;
|
||||
} else if (!launchdDBusEnv.isEmpty()) {
|
||||
// Show a warning and exit
|
||||
qCritical() << "Invalid " << KDECONNECT_SESSION_DBUS_LAUNCHD_ENV << "env: \""
|
||||
<< launchdDBusEnv << "\"";
|
||||
|
||||
QMessageBox::critical(nullptr, i18n("KDE Connect"),
|
||||
i18n("Cannot connect to DBus\n"
|
||||
"KDE Connect will quit"),
|
||||
QMessageBox::Abort,
|
||||
QMessageBox::Abort);
|
||||
} else {
|
||||
// Show a warning and exit
|
||||
qCritical() << "Fail to get launchctl" << KDECONNECT_SESSION_DBUS_LAUNCHD_ENV << "env";
|
||||
|
|
Loading…
Reference in a new issue