SHA256
1
0
forked from pool/k3b
k3b/device-detection-fix.patch
2010-12-14 10:03:16 +00:00

106 lines
3.6 KiB
Diff

Don't assume optical Solid device has also Solid::Block interface. For some reason it can lack it (hardware issue or Solid bug)
BUG: 249371
---
--- k3b/libk3bdevice/k3bdevicemanager.cpp 2010/09/09 18:58:01 1173574
+++ k3b/libk3bdevice/k3bdevicemanager.cpp 2010/09/09 19:01:06 1173575
@@ -1,6 +1,7 @@
/*
*
* Copyright (C) 2003-2009 Sebastian Trueg <trueg@k3b.org>
+ * Copyright (C) 2010 Michal Malek <michalm@jabster.pl>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2009 Sebastian Trueg <trueg@k3b.org>
@@ -290,7 +291,7 @@
emit changed( this );
emit changed();
-
+
qDeleteAll( devicesToDelete );
}
@@ -354,12 +355,13 @@
K3b::Device::Device* K3b::Device::DeviceManager::addDevice( const Solid::Device& solidDevice )
{
- if ( findDevice( solidDevice.as<Solid::Block>()->device() ) ) {
- kDebug() << "(K3b::Device::DeviceManager) dev " << solidDevice.as<Solid::Block>()->device() << " already found";
- return 0;
+ if( const Solid::Block* blockDevice = solidDevice.as<Solid::Block>() ) {
+ if( !findDevice( blockDevice->device() ) )
+ return addDevice( new K3b::Device::Device( solidDevice ) );
+ else
+ kDebug() << "(K3b::Device::DeviceManager) dev " << blockDevice->device() << " already found";
}
-
- return addDevice( new K3b::Device::Device( solidDevice ) );
+ return 0;
}
@@ -409,19 +411,21 @@
void K3b::Device::DeviceManager::removeDevice( const Solid::Device& dev )
{
- if( Device* device = findDevice( dev.as<Solid::Block>()->device() ) ) {
- d->cdReader.removeAll( device );
- d->dvdReader.removeAll( device );
- d->bdReader.removeAll( device );
- d->cdWriter.removeAll( device );
- d->dvdWriter.removeAll( device );
- d->bdWriter.removeAll( device );
- d->allDevices.removeAll( device );
+ if( const Solid::Block* blockDevice = dev.as<Solid::Block>() ) {
+ if( Device* device = findDevice( blockDevice->device() ) ) {
+ d->cdReader.removeAll( device );
+ d->dvdReader.removeAll( device );
+ d->bdReader.removeAll( device );
+ d->cdWriter.removeAll( device );
+ d->dvdWriter.removeAll( device );
+ d->bdWriter.removeAll( device );
+ d->allDevices.removeAll( device );
- emit changed( this );
- emit changed();
+ emit changed( this );
+ emit changed();
- delete device;
+ delete device;
+ }
}
}
--- k3b/src/k3bappdevicemanager.cpp 2010/09/09 18:58:01 1173574
+++ k3b/src/k3bappdevicemanager.cpp 2010/09/09 19:01:06 1173575
@@ -1,6 +1,7 @@
/*
*
* Copyright (C) 2005-2008 Sebastian Trueg <trueg@k3b.org>
+ * Copyright (C) 2010 Michal Malek <michalm@jabster.pl>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2008 Sebastian Trueg <trueg@k3b.org>
@@ -125,13 +126,15 @@
void K3b::AppDeviceManager::removeDevice( const Solid::Device& solidDev )
{
- if( findDevice( solidDev.as<Solid::Block>()->device() ) == currentDevice() )
- setCurrentDevice( 0 );
+ if( const Solid::Block* blockDevice = solidDev.as<Solid::Block>() ) {
+ if( findDevice( blockDevice->device() ) == currentDevice() )
+ setCurrentDevice( 0 );
- K3b::Device::DeviceManager::removeDevice( solidDev );
+ K3b::Device::DeviceManager::removeDevice( solidDev );
- if( currentDevice() == 0 && !allDevices().isEmpty() )
- setCurrentDevice( allDevices().first() );
+ if( currentDevice() == 0 && !allDevices().isEmpty() )
+ setCurrentDevice( allDevices().first() );
+ }
}