Prevent crash when going back from EraseDiskPage and then next.

This was caused by an invalid reference to a device model in the
partitioning preview widget after a PCM revert.
This commit is contained in:
Teo Mrnjavac 2015-03-13 15:55:06 +01:00
parent 9fcd8113e5
commit 4468e30317
2 changed files with 50 additions and 28 deletions

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -38,6 +38,7 @@
#include <QFormLayout>
#include <QListView>
#include <QLabel>
#include <QMutexLocker>
EraseDiskPage::EraseDiskPage( QWidget* parent )
: QWidget( parent )
@ -103,6 +104,9 @@ EraseDiskPage::init( PartitionCoreModule* core )
if ( dev )
doAutopartition( dev );
} );
connect( m_core, &PartitionCoreModule::isDirtyChanged,
this, &EraseDiskPage::updatePreviews );
}
@ -187,11 +191,27 @@ EraseDiskPage::doAutopartition( Device* dev )
PartitionInfo::setFormat( rootPartition, true );
m_core->createPartition( dev, rootPartition );
updatePreviews();
m_core->dumpQueue();
}
void
EraseDiskPage::updatePreviews()
{
QMutexLocker( &EraseDiskPage::m_previewsMutex );
cDebug() << "Updating partitioning preview widgets.";
qDeleteAll( m_previewFrame->children() );
m_previewFrame->layout()->deleteLater();
if ( m_drivesView->selectionModel()->currentIndex() == QModelIndex() )
{
cDebug() << "No disk selected, bailing out.";
return;
}
QFormLayout* layout = new QFormLayout;
m_previewFrame->setLayout( layout );
layout->setMargin( 0 );
@ -214,5 +234,3 @@ EraseDiskPage::doAutopartition( Device* dev )
layout->addRow( tr( "After:" ), preview );
}
}
m_core->dumpQueue();
}

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#ifndef ERASEDISKPAGE_H
#define ERASEDISKPAGE_H
#include <QMutex>
#include <QWidget>
class PartitionCoreModule;
@ -41,11 +42,14 @@ signals:
private:
void setNextEnabled( bool enabled );
void doAutopartition( Device* dev );
void updatePreviews();
QListView* m_drivesView;
PartitionCoreModule* m_core;
QWidget* m_previewFrame;
QMutex m_previewsMutex;
bool m_nextEnabled;
};