@@ -66,8 +66,11 @@ bool BlockDevices::contains(const QString &dbusObjectPath) const
66
66
67
67
void BlockDevices::remove (const QString &dbusObjectPath)
68
68
{
69
- Block *block = m_blockDevices.take (dbusObjectPath);
70
- block->deleteLater ();
69
+ if (contains (dbusObjectPath)) {
70
+ Block *block = m_blockDevices.take (dbusObjectPath);
71
+ clearPartitionWait (dbusObjectPath, false );
72
+ delete block;
73
+ }
71
74
}
72
75
73
76
Block *BlockDevices::device (const QString &dbusObjectPath) const
@@ -189,16 +192,22 @@ void BlockDevices::clearPartitionWait(const QString &dbusObjectPath, bool destro
189
192
190
193
void BlockDevices::removeInterfaces (const QString &dbusObjectPath, const QStringList &interfaces)
191
194
{
192
- if (contains (dbusObjectPath)) {
193
- UDisks2::Block *block = device (dbusObjectPath);
195
+ clearPartitionWait (dbusObjectPath, false );
196
+
197
+ UDisks2::Block *block = device (dbusObjectPath);
198
+ if (block) {
194
199
if (interfaces.contains (UDISKS2_FILESYSTEM_INTERFACE)) {
195
200
block->removeInterface (UDISKS2_FILESYSTEM_INTERFACE);
196
201
}
197
202
if (interfaces.contains (UDISKS2_ENCRYPTED_INTERFACE)) {
198
203
block->removeInterface (UDISKS2_ENCRYPTED_INTERFACE);
199
204
}
205
+
206
+ if (interfaces.contains (UDISKS2_BLOCK_INTERFACE)) {
207
+ delete block;
208
+ m_blockDevices.remove (dbusObjectPath);
209
+ }
200
210
}
201
- clearPartitionWait (dbusObjectPath, true );
202
211
}
203
212
204
213
bool BlockDevices::isExternal (const QString &dbusObjectPath)
@@ -210,7 +219,8 @@ bool BlockDevices::isExternal(const QString &dbusObjectPath)
210
219
void BlockDevices::blockCompleted ()
211
220
{
212
221
Block *completedBlock = qobject_cast<Block *>(sender ());
213
- if (completedBlock->isPartitionTable () || (completedBlock->hasInterface (UDISKS2_BLOCK_INTERFACE) && completedBlock->interfaceCount () == 1 )) {
222
+ if (completedBlock->isValid () && (completedBlock->isPartitionTable () ||
223
+ (completedBlock->hasInterface (UDISKS2_BLOCK_INTERFACE) && completedBlock->interfaceCount () == 1 )) ){
214
224
qCInfo (lcMemoryCardLog) << " Start waiting for block" << completedBlock->device ();
215
225
waitPartition (completedBlock);
216
226
return ;
0 commit comments