check the constraints (first and last sector min and max) again after aligning
a partition to make sure we're not going over those. of course PartitionTable::alignPartition() shouldn't move first and last sector to anywhere it's not allowed to, but currently it seems buggy enough to do so and the check won't hurt. PartitionTable::alignPartition() still needs to be fixed, of course. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1114084
This commit is contained in:
parent
d349fbd591
commit
3d6b74453e
10
TODO
10
TODO
|
@ -23,7 +23,15 @@ Bugs to fix for 1.1:
|
|||
* moving an empty extended partition is currently not allowed, but attempting
|
||||
to still moves it by a few pixels
|
||||
|
||||
* resizing a partition with no free space before or after it is buggy
|
||||
* move/resize and aligning is badly broken, still: as long as align is on,
|
||||
moving the start beyond the first possible sector breaks. moving a partition
|
||||
to the left changes its size and probably more...
|
||||
|
||||
* aligning a partition from the part resizer widget that absolutely cannot go
|
||||
to the left or right still causes its start and end to be realigned to the
|
||||
left and right respectively, it seems. this is now prevented in the part
|
||||
resizer (a measure that doesn't hurt), but PartitionTable::alignPartition()
|
||||
shouldn't make such mistakes in the first place, of course.
|
||||
|
||||
===============================================================================
|
||||
|
||||
|
|
|
@ -165,6 +165,14 @@ void PartResizerWidget::mousePressEvent(QMouseEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
bool PartResizerWidget::checkConstraints(qint64 first, qint64 last) const
|
||||
{
|
||||
return (maximumFirstSector() < 0 || first <= maximumFirstSector()) &&
|
||||
(minimumFirstSector() < 0 || first >= minimumFirstSector()) &&
|
||||
(minimumLastSector() < 0 || last >= minimumLastSector()) &&
|
||||
(maximumLastSector() < 0 || last <= maximumLastSector());
|
||||
}
|
||||
|
||||
bool PartResizerWidget::movePartition(qint64 newFirstSector)
|
||||
{
|
||||
if (maximumFirstSector() > -1 && newFirstSector > maximumFirstSector())
|
||||
|
@ -197,11 +205,7 @@ bool PartResizerWidget::movePartition(qint64 newFirstSector)
|
|||
if (newLastSector == partition().lastSector())
|
||||
return false;
|
||||
|
||||
if (newLastSector - newFirstSector + 1 != partition().length() ||
|
||||
(maximumFirstSector() > -1 && newFirstSector > maximumFirstSector()) ||
|
||||
(minimumFirstSector() > -1 && newFirstSector < minimumFirstSector()) ||
|
||||
(minimumLastSector() > -1 && newLastSector < minimumLastSector()) ||
|
||||
(maximumLastSector() > -1 && newLastSector > maximumLastSector()))
|
||||
if (newLastSector - newFirstSector + 1 != partition().length() || !checkConstraints(newFirstSector, newLastSector))
|
||||
{
|
||||
kWarning() << "constraints not satisfied while trying to move partition " << partition().deviceNode();
|
||||
return false;
|
||||
|
@ -225,8 +229,23 @@ bool PartResizerWidget::movePartition(qint64 newFirstSector)
|
|||
partition().fileSystem().setLastSector(newLastSector);
|
||||
|
||||
if (align())
|
||||
{
|
||||
device().partitionTable()->alignPartition(device(), partition());
|
||||
|
||||
if (!checkConstraints(partition().firstSector(), partition().lastSector()))
|
||||
{
|
||||
kWarning() << "constraints not satisfied after aligning moved partition " << partition().deviceNode();
|
||||
|
||||
partition().setFirstSector(originalFirst);
|
||||
partition().fileSystem().setFirstSector(originalFirst);
|
||||
|
||||
partition().setLastSector(originalLast);
|
||||
partition().fileSystem().setLastSector(originalLast);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (originalFirst != partition().firstSector() || originalLast != partition().lastSector())
|
||||
{
|
||||
resizeLogicals();
|
||||
|
|
|
@ -126,6 +126,8 @@ class PartResizerWidget : public QWidget
|
|||
QWidget* draggedWidget() { return m_DraggedWidget; }
|
||||
const QWidget* draggedWidget() const { return m_DraggedWidget; }
|
||||
|
||||
bool checkConstraints(qint64 first, qint64 last) const;
|
||||
|
||||
private:
|
||||
Device* m_Device;
|
||||
Partition* m_Partition;
|
||||
|
|
Loading…
Reference in New Issue