Use for loop with iterators when removing mount points.
This commit is contained in:
parent
b38db099e0
commit
6f8cde5520
|
@ -56,7 +56,7 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
|
||||||
QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath();
|
QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath();
|
||||||
if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints
|
if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints
|
||||||
entryFound = true;
|
entryFound = true;
|
||||||
entry.append(&e);
|
entry.push_back(&e);
|
||||||
mountPointList = possibleMountPoints(e.deviceNode());
|
mountPointList = possibleMountPoints(e.deviceNode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
|
||||||
fsName = partition().fileSystem().name();
|
fsName = partition().fileSystem().name();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fstabEntries.append(FstabEntry(m_deviceNode, QString(), fsName, QString()));
|
m_fstabEntries.push_back(FstabEntry(m_deviceNode, QString(), fsName, QString()));
|
||||||
entry.append(&m_fstabEntries.last());
|
entry.push_back(&m_fstabEntries.back());
|
||||||
}
|
}
|
||||||
currentEntry = entry[0];
|
currentEntry = entry[0];
|
||||||
editPath().addItems(mountPointList);
|
editPath().addItems(mountPointList);
|
||||||
|
@ -174,24 +174,24 @@ void EditMountPointDialogWidget::buttonSelectClicked(bool)
|
||||||
|
|
||||||
void EditMountPointDialogWidget::removeMountPoint()
|
void EditMountPointDialogWidget::removeMountPoint()
|
||||||
{
|
{
|
||||||
int i=0;
|
for (auto it = fstabEntries().begin(); it != fstabEntries().end(); ) {
|
||||||
for (const auto &e : fstabEntries()) {
|
if (editPath().count() <= 1 && (
|
||||||
if(editPath().count()<=1 && ((e.fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().isEmpty() ) || (e.fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty()) ||
|
(it->fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().isEmpty() ) ||
|
||||||
(e.fsSpec().contains(partition().fileSystem().label()) && !partition().fileSystem().label().isEmpty()) || (e.fsSpec().contains(partition().label()) && !partition().label().isEmpty() ) || (e.fsSpec().contains(partition().uuid()) && !partition().uuid().isEmpty() )))
|
(it->fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty() ) ||
|
||||||
{
|
(it->fsSpec().contains(partition().fileSystem().label()) && !partition().fileSystem().label().isEmpty()) ||
|
||||||
fstabEntries().removeAt(i);
|
(it->fsSpec().contains(partition().label()) && !partition().label().isEmpty() ) ||
|
||||||
|
(it->fsSpec().contains(partition().uuid()) && !partition().uuid().isEmpty() )))
|
||||||
|
{
|
||||||
|
fstabEntries().erase(it);
|
||||||
partition().setMountPoint(QString());
|
partition().setMountPoint(QString());
|
||||||
i--;
|
}
|
||||||
}
|
else if (editPath().count() > 1 && ((&*it == currentEntry)))
|
||||||
else if(editPath().count()>1 && ((&e == currentEntry)))
|
{
|
||||||
{
|
fstabEntries().erase(it);
|
||||||
fstabEntries().removeAt(i);
|
|
||||||
editPath().removeItem(editPath().currentIndex());
|
editPath().removeItem(editPath().currentIndex());
|
||||||
partition().setMountPoint(editPath().itemText(editPath().currentIndex()));
|
partition().setMountPoint(editPath().itemText(editPath().currentIndex()));
|
||||||
i--;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FstabEntryList m_fstabEntries;
|
FstabEntryList m_fstabEntries;
|
||||||
QList<FstabEntry *> entry;
|
QList<FstabEntry *> entry; // All fstab entries for this partition
|
||||||
FstabEntry *currentEntry;
|
FstabEntry *currentEntry;
|
||||||
Partition& m_Partition;
|
Partition& m_Partition;
|
||||||
QString m_Options;
|
QString m_Options;
|
||||||
|
|
Loading…
Reference in New Issue