[locale] Simplify allocation, guard against crashes if the dialog is deleted.
This commit is contained in:
parent
66eacce654
commit
abc98cfa79
@ -38,6 +38,7 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPointer>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
@ -285,31 +286,31 @@ LocalePage::locationChanged( const CalamaresUtils::Locale::TZZone* location )
|
|||||||
void
|
void
|
||||||
LocalePage::changeLocale()
|
LocalePage::changeLocale()
|
||||||
{
|
{
|
||||||
LCLocaleDialog* dlg
|
QPointer< LCLocaleDialog > dlg(
|
||||||
= new LCLocaleDialog( m_config->localeConfiguration().language(), m_config->supportedLocales(), this );
|
new LCLocaleDialog( m_config->localeConfiguration().language(), m_config->supportedLocales(), this ) );
|
||||||
dlg->exec();
|
dlg->exec();
|
||||||
if ( dlg->result() == QDialog::Accepted && !dlg->selectedLCLocale().isEmpty() )
|
if ( dlg && dlg->result() == QDialog::Accepted && !dlg->selectedLCLocale().isEmpty() )
|
||||||
{
|
{
|
||||||
m_config->setLanguageExplicitly( dlg->selectedLCLocale() );
|
m_config->setLanguageExplicitly( dlg->selectedLCLocale() );
|
||||||
updateGlobalLocale();
|
updateGlobalLocale();
|
||||||
updateLocaleLabels();
|
updateLocaleLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg->deleteLater();
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalePage::changeFormats()
|
LocalePage::changeFormats()
|
||||||
{
|
{
|
||||||
LCLocaleDialog* dlg
|
QPointer< LCLocaleDialog > dlg(
|
||||||
= new LCLocaleDialog( m_config->localeConfiguration().lc_numeric, m_config->supportedLocales(), this );
|
new LCLocaleDialog( m_config->localeConfiguration().lc_numeric, m_config->supportedLocales(), this ) );
|
||||||
dlg->exec();
|
dlg->exec();
|
||||||
if ( dlg->result() == QDialog::Accepted && !dlg->selectedLCLocale().isEmpty() )
|
if ( dlg && dlg->result() == QDialog::Accepted && !dlg->selectedLCLocale().isEmpty() )
|
||||||
{
|
{
|
||||||
m_config->setLCLocaleExplicitly( dlg->selectedLCLocale() );
|
m_config->setLCLocaleExplicitly( dlg->selectedLCLocale() );
|
||||||
updateLocaleLabels();
|
updateLocaleLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg->deleteLater();
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user