Keep an immutable copy for every scanned Device* to avoid rescans.
This commit is contained in:
parent
0053721896
commit
6093042863
@ -97,6 +97,7 @@ isIso9660( const Device* device )
|
||||
PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device )
|
||||
: device( _device )
|
||||
, partitionModel( new PartitionModel )
|
||||
, immutableDevice( new Device( *_device ) )
|
||||
{}
|
||||
|
||||
PartitionCoreModule::DeviceInfo::~DeviceInfo()
|
||||
@ -235,7 +236,7 @@ PartitionCoreModule::bootLoaderModel() const
|
||||
}
|
||||
|
||||
PartitionModel*
|
||||
PartitionCoreModule::partitionModelForDevice( Device* device ) const
|
||||
PartitionCoreModule::partitionModelForDevice( const Device* device ) const
|
||||
{
|
||||
DeviceInfo* info = infoForDevice( device );
|
||||
Q_ASSERT( info );
|
||||
@ -244,14 +245,14 @@ PartitionCoreModule::partitionModelForDevice( Device* device ) const
|
||||
|
||||
|
||||
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();
|
||||
cDebug() << "Creating immutable copy for node:" << node;
|
||||
Device* deviceBefore = backend->scanDevice( node );
|
||||
return deviceBefore;
|
||||
return info->immutableDevice.data();
|
||||
}
|
||||
|
||||
|
||||
@ -566,12 +567,15 @@ PartitionCoreModule::scanForEfiSystemPartitions()
|
||||
}
|
||||
|
||||
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 )
|
||||
return deviceInfo;
|
||||
if ( ( *it )->device.data() == device )
|
||||
return *it;
|
||||
if ( ( *it )->immutableDevice.data() == device )
|
||||
return *it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
|
||||
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.
|
||||
// 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.
|
||||
// -- Teo 4/2015
|
||||
//FIXME: make this horrible method private. -- Teo 12/2015
|
||||
static Device* createImmutableDeviceCopy( Device* device );
|
||||
Device* immutableDeviceCopy( const Device* device );
|
||||
|
||||
QAbstractItemModel* bootLoaderModel() const;
|
||||
|
||||
@ -147,6 +147,7 @@ private:
|
||||
~DeviceInfo();
|
||||
QScopedPointer< Device > device;
|
||||
QScopedPointer< PartitionModel > partitionModel;
|
||||
const QScopedPointer< Device > immutableDevice;
|
||||
QList< Calamares::job_ptr > jobs;
|
||||
|
||||
void forgetChanges();
|
||||
@ -166,7 +167,7 @@ private:
|
||||
void updateIsDirty();
|
||||
void scanForEfiSystemPartitions();
|
||||
|
||||
DeviceInfo* infoForDevice( Device* ) const;
|
||||
DeviceInfo* infoForDevice( const Device* ) const;
|
||||
|
||||
OsproberEntryList m_osproberLines;
|
||||
|
||||
|
@ -817,7 +817,7 @@ ChoicePage::updateDeviceStatePreview()
|
||||
m_beforePartitionLabelsView = new PartitionLabelsView( m_previewBeforeFrame );
|
||||
m_beforePartitionLabelsView->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
||||
|
||||
Device* deviceBefore = m_core->createImmutableDeviceCopy( currentDevice );
|
||||
Device* deviceBefore = m_core->immutableDeviceCopy( currentDevice );
|
||||
|
||||
PartitionModel* model = new PartitionModel( m_beforePartitionBarsView );
|
||||
model->init( deviceBefore, m_core->osproberEntries() );
|
||||
|
Loading…
Reference in New Issue
Block a user