Commit 6ff53917 authored by Gleb Popov's avatar Gleb Popov

Cancel processing of probers results if the block object is gone.

Can happen if some probe takes a lot of time and the media gets ejected (SD cards).
parent 4194977fc851
......@@ -101,7 +101,7 @@ void ObjectManager::addBlock(QString dev)
void ObjectManager::updateBlock(QString dev)
{
auto* b = m_blockObjects[dev];
auto* b = m_blockObjects.value(dev);
if(b->probesDone.all())
{
......@@ -133,7 +133,7 @@ void ObjectManager::removeBlock(QString dev)
return;
auto* b = m_blockObjects.take(dev);
auto* d = m_driveObjects[b->driveName()];
auto* d = m_driveObjects.value(b->driveName());
qDebug() << "Unregistering " + b->dbusPath.path();
QStringList ifaces;
......@@ -343,10 +343,15 @@ void ObjectManager::addZFSDataset(const ZFSInfo& zfsInfo)
void ObjectManager::startFilesystemProbe(Block* b)
{
auto prober = new FilesystemProber(b->device());
const QString devName = b->name;
QObject::connect(prober, &FilesystemProber::finished, this,
[this, b](QString fs)
[this, devName](QString fs)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
qDebug() << "Finished FS probe on " << b->name;
if(!fs.isEmpty())
filesystemAdded(b, fs);
......@@ -367,21 +372,35 @@ void ObjectManager::startGeomProbe(Block* b)
if(b->name.startsWith("md"))
b->hasNoDrive = true;
const QString devName = b->name;
QObject::connect(prober, &GeomProber::gotLabels, this,
[this, b](QStringList labels)
[this, devName](QStringList labels)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
b->labels = labels;
});
QObject::connect(prober, &GeomProber::gotDisk, this,
[this, b](DiskInfo di)
[this, devName](DiskInfo di)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
b->size = di.mediaSize();
b->description = di.descr();
b->identifier = di.ident();
});
QObject::connect(prober, &GeomProber::gotPartTable, this,
[this, b](PartTableInfo pi)
[this, devName](PartTableInfo pi)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
// do not create BlockPartTable when called from updateBlock()
if(!b->bPartTable)
b->bPartTable = new BlockPartTable(b);
......@@ -392,13 +411,21 @@ void ObjectManager::startGeomProbe(Block* b)
b->bPartTable->partitionBlockNames << it.key();
});
QObject::connect(prober, &GeomProber::gotPart, this,
[this, b](QString tableBlockName, Part partInfo)
[this, devName](QString tableBlockName, Part partInfo)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
addPartition(b, tableBlockName, partInfo);
});
QObject::connect(prober, &GeomProber::finished, this,
[this, b]()
[this, devName]()
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
b->probesDone.set(GEOM_PROBE);
qDebug() << "Finished GEOM probe on " << b->name;
if(b->probesDone.all())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment