Keep an immutable copy for every scanned Device* to avoid rescans.
This commit is contained in:
parent
44368db30a
commit
6d0965ef3f
@ -97,6 +97,7 @@ isIso9660( const Device* device )
|
|||||||
PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device )
|
PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device )
|
||||||
: device( _device )
|
: device( _device )
|
||||||
, partitionModel( new PartitionModel )
|
, partitionModel( new PartitionModel )
|
||||||
|
, immutableDevice( new Device( *_device ) )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
PartitionCoreModule::DeviceInfo::~DeviceInfo()
|
PartitionCoreModule::DeviceInfo::~DeviceInfo()
|
||||||
@ -235,7 +236,7 @@ PartitionCoreModule::bootLoaderModel() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
PartitionModel*
|
PartitionModel*
|
||||||
PartitionCoreModule::partitionModelForDevice( Device* device ) const
|
PartitionCoreModule::partitionModelForDevice( const Device* device ) const
|
||||||
{
|
{
|
||||||
DeviceInfo* info = infoForDevice( device );
|
DeviceInfo* info = infoForDevice( device );
|
||||||
Q_ASSERT( info );
|
Q_ASSERT( info );
|
||||||
@ -244,14 +245,14 @@ PartitionCoreModule::partitionModelForDevice( Device* device ) const
|
|||||||
|
|
||||||
|
|
||||||
Device*
|
Device*
|
||||||
PartitionCoreModule::createImmutableDeviceCopy( Device* device )
|
PartitionCoreModule::immutableDeviceCopy( const Device* device )
|
||||||
{
|
{
|
||||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
Q_ASSERT( device );
|
||||||
|
DeviceInfo* info = infoForDevice( device );
|
||||||
|
if ( !info )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
QString node = device->deviceNode();
|
return info->immutableDevice.data();
|
||||||
cDebug() << "Creating immutable copy for node:" << node;
|
|
||||||
Device* deviceBefore = backend->scanDevice( node );
|
|
||||||
return deviceBefore;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -566,12 +567,15 @@ PartitionCoreModule::scanForEfiSystemPartitions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
PartitionCoreModule::DeviceInfo*
|
PartitionCoreModule::DeviceInfo*
|
||||||
PartitionCoreModule::infoForDevice( Device* device ) const
|
PartitionCoreModule::infoForDevice( const Device* device ) const
|
||||||
{
|
{
|
||||||
for ( auto deviceInfo : m_deviceInfos )
|
for ( auto it = m_deviceInfos.constBegin();
|
||||||
|
it != m_deviceInfos.constEnd(); ++it )
|
||||||
{
|
{
|
||||||
if ( deviceInfo->device.data() == device )
|
if ( ( *it )->device.data() == device )
|
||||||
return deviceInfo;
|
return *it;
|
||||||
|
if ( ( *it )->immutableDevice.data() == device )
|
||||||
|
return *it;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
|
|
||||||
DeviceModel* deviceModel() const;
|
DeviceModel* deviceModel() const;
|
||||||
|
|
||||||
PartitionModel* partitionModelForDevice( Device* device ) const;
|
PartitionModel* partitionModelForDevice( const Device* device ) const;
|
||||||
|
|
||||||
//HACK: all devices change over time, and together make up the state of the CoreModule.
|
//HACK: all devices change over time, and together make up the state of the CoreModule.
|
||||||
// However this makes it hard to show the *original* state of a device.
|
// However this makes it hard to show the *original* state of a device.
|
||||||
@ -77,7 +77,7 @@ public:
|
|||||||
// This should probably be redone some other way.
|
// This should probably be redone some other way.
|
||||||
// -- Teo 4/2015
|
// -- Teo 4/2015
|
||||||
//FIXME: make this horrible method private. -- Teo 12/2015
|
//FIXME: make this horrible method private. -- Teo 12/2015
|
||||||
static Device* createImmutableDeviceCopy( Device* device );
|
Device* immutableDeviceCopy( const Device* device );
|
||||||
|
|
||||||
QAbstractItemModel* bootLoaderModel() const;
|
QAbstractItemModel* bootLoaderModel() const;
|
||||||
|
|
||||||
@ -147,6 +147,7 @@ private:
|
|||||||
~DeviceInfo();
|
~DeviceInfo();
|
||||||
QScopedPointer< Device > device;
|
QScopedPointer< Device > device;
|
||||||
QScopedPointer< PartitionModel > partitionModel;
|
QScopedPointer< PartitionModel > partitionModel;
|
||||||
|
const QScopedPointer< Device > immutableDevice;
|
||||||
QList< Calamares::job_ptr > jobs;
|
QList< Calamares::job_ptr > jobs;
|
||||||
|
|
||||||
void forgetChanges();
|
void forgetChanges();
|
||||||
@ -166,7 +167,7 @@ private:
|
|||||||
void updateIsDirty();
|
void updateIsDirty();
|
||||||
void scanForEfiSystemPartitions();
|
void scanForEfiSystemPartitions();
|
||||||
|
|
||||||
DeviceInfo* infoForDevice( Device* ) const;
|
DeviceInfo* infoForDevice( const Device* ) const;
|
||||||
|
|
||||||
OsproberEntryList m_osproberLines;
|
OsproberEntryList m_osproberLines;
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ ChoicePage::updateDeviceStatePreview()
|
|||||||
m_beforePartitionLabelsView = new PartitionLabelsView( m_previewBeforeFrame );
|
m_beforePartitionLabelsView = new PartitionLabelsView( m_previewBeforeFrame );
|
||||||
m_beforePartitionLabelsView->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
m_beforePartitionLabelsView->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
||||||
|
|
||||||
Device* deviceBefore = m_core->createImmutableDeviceCopy( currentDevice );
|
Device* deviceBefore = m_core->immutableDeviceCopy( currentDevice );
|
||||||
|
|
||||||
PartitionModel* model = new PartitionModel( m_beforePartitionBarsView );
|
PartitionModel* model = new PartitionModel( m_beforePartitionBarsView );
|
||||||
model->init( deviceBefore, m_core->osproberEntries() );
|
model->init( deviceBefore, m_core->osproberEntries() );
|
||||||
|
Loading…
Reference in New Issue
Block a user