Skip to content
Snippets Groups Projects
Commit 6c7c24aad721 authored by Gleb Popov's avatar Gleb Popov
Browse files

Wrap the duplicated checking code into a macro.

parent b1ff813e2d0f
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,11 @@
#include "camcontrolprober.h"
#include "zfsprober.h"
// We have to run this check whenever a probe is finished, because the object
// being probed may be deleted meanwhile.
#define GET_BLOCK_OR_RETURN_IF_GONE(name) Block* b = m_blockObjects.value(name, nullptr); \
if(!b) return;
DBUSManagerStruct ObjectManager::GetManagedObjects()
{
DBUSManagerStruct ret;
......@@ -391,9 +396,7 @@
QObject::connect(prober, &FilesystemProber::finished, this,
[this, devName](QString fs)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
GET_BLOCK_OR_RETURN_IF_GONE(devName);
qDebug() << "Finished FS probe on " << b->name;
if(!fs.isEmpty())
......@@ -420,12 +423,10 @@
QObject::connect(prober, &GeomProber::gotLabels, this,
[this, devName](QStringList labels)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
GET_BLOCK_OR_RETURN_IF_GONE(devName);
b->labels = labels;
});
QObject::connect(prober, &GeomProber::gotDisk, this,
[this, devName](DiskInfo di)
{
......@@ -426,12 +427,10 @@
b->labels = labels;
});
QObject::connect(prober, &GeomProber::gotDisk, this,
[this, devName](DiskInfo di)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
GET_BLOCK_OR_RETURN_IF_GONE(devName);
b->size = di.mediaSize();
b->description = di.descr();
......@@ -440,9 +439,7 @@
QObject::connect(prober, &GeomProber::gotPartTable, this,
[this, devName](PartTableInfo pi)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
GET_BLOCK_OR_RETURN_IF_GONE(devName);
// do not create BlockPartTable when called from updateBlock()
if(!b->bPartTable)
......@@ -456,12 +453,10 @@
QObject::connect(prober, &GeomProber::gotPart, this,
[this, devName](QString tableBlockName, Part partInfo)
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
GET_BLOCK_OR_RETURN_IF_GONE(devName);
addPartition(b, tableBlockName, partInfo);
});
QObject::connect(prober, &GeomProber::finished, this,
[this, devName]()
{
......@@ -462,12 +457,10 @@
addPartition(b, tableBlockName, partInfo);
});
QObject::connect(prober, &GeomProber::finished, this,
[this, devName]()
{
Block* b = m_blockObjects.value(devName);
if(!b)
return;
GET_BLOCK_OR_RETURN_IF_GONE(devName);
b->probesDone.set(GEOM_PROBE);
qDebug() << "Finished GEOM probe on " << b->name;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment