Changeset View
Changeset View
Standalone View
Standalone View
dataengines/devicenotifications/ksolidnotify.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
67 | { | 67 | { | ||
68 | if (m_devices[udi].is<Solid::StorageVolume>()) { | 68 | if (m_devices[udi].is<Solid::StorageVolume>()) { | ||
69 | Solid::StorageAccess *access = m_devices[udi].as<Solid::StorageAccess>(); | 69 | Solid::StorageAccess *access = m_devices[udi].as<Solid::StorageAccess>(); | ||
70 | if (access) { | 70 | if (access) { | ||
71 | disconnect(access, nullptr, this, nullptr); | 71 | disconnect(access, nullptr, this, nullptr); | ||
72 | } | 72 | } | ||
73 | } | 73 | } | ||
74 | m_devices.remove(udi); | 74 | m_devices.remove(udi); | ||
75 | emit clearNotification(udi); | ||||
75 | } | 76 | } | ||
76 | 77 | | |||
77 | bool KSolidNotify::isSafelyRemovable(const QString &udi) const | 78 | bool KSolidNotify::isSafelyRemovable(const QString &udi) const | ||
78 | { | 79 | { | ||
79 | Solid::Device parent = m_devices[udi].parent(); | 80 | Solid::Device parent = m_devices[udi].parent(); | ||
80 | if (parent.is<Solid::StorageDrive>()) { | 81 | if (parent.is<Solid::StorageDrive>()) { | ||
81 | Solid::StorageDrive *drive = parent.as<Solid::StorageDrive>(); | 82 | Solid::StorageDrive *drive = parent.as<Solid::StorageDrive>(); | ||
82 | return (!drive->isInUse() && (drive->isHotpluggable() || drive->isRemovable())); | 83 | return (!drive->isInUse() && (drive->isHotpluggable() || drive->isRemovable())); | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 126 | connect(p, static_cast<void (QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), [=](int,QProcess::ExitStatus) { | |||
143 | p->deleteLater(); | 144 | p->deleteLater(); | ||
144 | }); | 145 | }); | ||
145 | p->start(QStringLiteral("lsof"), {QStringLiteral("-t"), devicePath}); | 146 | p->start(QStringLiteral("lsof"), {QStringLiteral("-t"), devicePath}); | ||
146 | // p.start(QStringLiteral("fuser"), {QStringLiteral("-m"), devicePath}); | 147 | // p.start(QStringLiteral("fuser"), {QStringLiteral("-m"), devicePath}); | ||
147 | } | 148 | } | ||
148 | 149 | | |||
149 | void KSolidNotify::onSolidReply(SolidReplyType type, Solid::ErrorType error, const QVariant &errorData, const QString &udi) | 150 | void KSolidNotify::onSolidReply(SolidReplyType type, Solid::ErrorType error, const QVariant &errorData, const QString &udi) | ||
150 | { | 151 | { | ||
152 | if ((error == Solid::ErrorType::NoError) && (type == SolidReplyType::Setup)) { | ||||
broulik: Move this into the relevant `case` below, please | |||||
I considered this and did not because of the early return. bruns: I considered this and did not because of the early return.
All the other `case`s just do a… | |||||
153 | emit clearNotification(udi); | ||||
154 | return; | ||||
155 | } | ||||
156 | | ||||
151 | QString errorMsg; | 157 | QString errorMsg; | ||
152 | 158 | | |||
153 | switch (error) { | 159 | switch (error) { | ||
154 | case Solid::ErrorType::NoError: | 160 | case Solid::ErrorType::NoError: | ||
155 | if (type != SolidReplyType::Setup && isSafelyRemovable(udi)) { | 161 | if (type != SolidReplyType::Setup && isSafelyRemovable(udi)) { | ||
156 | errorMsg = i18n("This device can now be safely removed."); | 162 | errorMsg = i18n("This device can now be safely removed."); | ||
157 | } | 163 | } | ||
158 | break; | 164 | break; | ||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
Move this into the relevant case below, please