[kde-freebsd] kde / device-notifier treats ufs partition as removable disk?
Andriy Gapon
avg at FreeBSD.org
Thu Mar 15 09:26:58 UTC 2012
on 15/03/2012 09:31 Andriy Gapon said the following:
> I'd rather fix the Device Notifier behavior.
The following patch seems to work.
The idea is to correctly go from a filesystem Solid device to its StorageDrive
device ancestor while ignoring intermediate volume/partition devices.
A direct parent of a filesystem device could be a partition which does not
support StorageDrive interface and thus nothing intelligent could be deduced
about its hot plug properties.
--- plasma/generic/applets/devicenotifier/devicenotifier.cpp.orig 2012-03-15
10:19:48.791075156 +0200
+++ plasma/generic/applets/devicenotifier/devicenotifier.cpp 2012-03-15
11:14:46.896071677 +0200
@@ -241,6 +241,20 @@ QGraphicsWidget *DeviceNotifier::graphic
return m_dialog->dialog();
}
+namespace {
+ Solid::StorageDrive * getStorageDriveParent(const Solid::Device &device)
+ {
+ Solid::Device parentDevice = device;
+
+ while ((parentDevice = parentDevice.parent()).isValid()) {
+ if (parentDevice.is<Solid::StorageDrive>()) {
+ return parentDevice.as<Solid::StorageDrive>();
+ }
+ }
+ return NULL;
+ }
+}
+
void DeviceNotifier::fillPreviousDevices()
{
m_fillingPreviousDevices = true;
@@ -249,8 +263,7 @@ void DeviceNotifier::fillPreviousDevices
foreach (const Solid::Device &device, list) {
// We manually add non-removable devices that are a priori ignored
// discard swap and partition tables
- Solid::Device parentDevice = device.parent();
- Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
+ Solid::StorageDrive *drive = getStorageDriveParent(device);
const Solid::StorageVolume *volume = device.as<Solid::StorageVolume>();
if (drive && (!drive->isHotpluggable() && !drive->isRemovable()) &&
(volume->usage() == Solid::StorageVolume::FileSystem)) {
@@ -364,15 +377,12 @@ void DeviceNotifier::deviceAdded(const S
{
const QString udi = device.udi();
if (m_showDevices == NonRemovableOnly) {
- Solid::Device parentDevice = device.parent();
- Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
+ Solid::StorageDrive *drive = getStorageDriveParent(device);
if (drive && (drive->isHotpluggable() || drive->isRemovable())) {
return;
}
} else if (m_showDevices == RemovableOnly) {
- Solid::Device device = Solid::Device(udi);
- Solid::Device parentDevice = device.parent();
- Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
+ Solid::StorageDrive *drive = getStorageDriveParent(device);
if (drive && (!drive->isHotpluggable() && !drive->isRemovable())) {
return;
}
--
Andriy Gapon
More information about the kde-freebsd
mailing list