Skip to content

Commit

Permalink
Add objects() method to the Job
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Nov 22, 2018
1 parent b8d96da commit 12bb39b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/udisks2job.cpp
Expand Up @@ -58,8 +58,7 @@ UDisks2::Job::Job(const QString &path, const QVariantMap &data, QObject *parent)
}

connect(Monitor::instance(), &Monitor::errorMessage, this, [this](const QString &objectPath, const QString &errorName) {
QStringList objects = value(UDISKS2_JOB_KEY_OBJECTS).toStringList();
if (objects.contains(objectPath) && errorName == UDISKS2_ERROR_DEVICE_BUSY) {
if (objects().contains(objectPath) && errorName == UDISKS2_ERROR_DEVICE_BUSY) {
m_message = errorName;
if (!isCompleted() && deviceBusy()) {
updateCompleted(false, m_message);
Expand Down Expand Up @@ -100,6 +99,11 @@ bool UDisks2::Job::deviceBusy() const
return m_message == UDISKS2_ERROR_TARGET_BUSY || m_message == UDISKS2_ERROR_DEVICE_BUSY;
}

QStringList UDisks2::Job::objects() const
{
return value(UDISKS2_JOB_KEY_OBJECTS).toStringList();
}

QString UDisks2::Job::path() const
{
return m_path;
Expand Down
2 changes: 2 additions & 0 deletions src/udisks2job_p.h
Expand Up @@ -68,6 +68,8 @@ class Job : public QObject
QString message() const;
bool deviceBusy() const;

QStringList objects() const;

QString path() const;
QVariant value(const QString &key) const;

Expand Down
2 changes: 1 addition & 1 deletion src/udisks2monitor.cpp
Expand Up @@ -369,7 +369,7 @@ void UDisks2::Monitor::updatePartitionStatus(const UDisks2::Job *job, bool succe
{
UDisks2::Job::Operation operation = job->operation();
PartitionManagerPrivate::Partitions affectedPartitions;
lookupPartitions(affectedPartitions, job->value(UDISKS2_JOB_KEY_OBJECTS).toStringList());
lookupPartitions(affectedPartitions, job->objects());
if (operation == UDisks2::Job::Lock || operation == UDisks2::Job::Unlock) {
for (auto partition : affectedPartitions) {
Partition::Status oldStatus = partition->status;
Expand Down

0 comments on commit 12bb39b

Please sign in to comment.