Skip to content

Commit 0f0162d

Browse files
committed
check ref to settings
1 parent 1eb3d8b commit 0f0162d

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/network/nm/wireless.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <qloggingcategory.h>
1313
#include <qnamespace.h>
1414
#include <qobject.h>
15+
#include <qpointer.h>
1516
#include <qstring.h>
1617
#include <qtmetamacros.h>
1718
#include <qtypes.h>
@@ -438,7 +439,7 @@ void NMWirelessDevice::registerFrontendNetwork(NMWirelessNetwork* net) {
438439
[this, net](const QString& psk) {
439440
NMSettingsMap settings;
440441
settings["802-11-wireless-security"]["psk"] = psk;
441-
if (auto* ref = net->referenceSettings()) {
442+
if (const QPointer<NMSettings> ref = net->referenceSettings()) {
442443
auto* call = ref->updateSettings(settings);
443444
QObject::connect(
444445
call,
@@ -451,10 +452,15 @@ void NMWirelessDevice::registerFrontendNetwork(NMWirelessNetwork* net) {
451452
qCInfo(logNetworkManager)
452453
<< "Failed to write PSK for" << this->path() + ":" << reply.error().message();
453454
} else {
454-
emit this->activateConnection(
455-
QDBusObjectPath(ref->path()),
456-
QDBusObjectPath(this->path())
457-
);
455+
if (!ref) {
456+
qCInfo(logNetworkManager) << "Failed to connectWithPsk to"
457+
<< this->path() + ": The settings disappeared.";
458+
} else {
459+
emit this->activateConnection(
460+
QDBusObjectPath(ref->path()),
461+
QDBusObjectPath(this->path())
462+
);
463+
}
458464
}
459465
delete call;
460466
}

0 commit comments

Comments
 (0)