Fixed crash after retranslation UI.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-09-03 13:31:23 +03:00
parent 9a5fa4b026
commit 3d297d657c
2 changed files with 51 additions and 17 deletions

View File

@ -62,9 +62,9 @@ TapeConfigDialog::TapeConfigDialog(QWidget *parent)
pathPage = new TapePathPage(); pathPage = new TapePathPage();
pagesWidget->addWidget(pathPage); pagesWidget->addWidget(pathPage);
QPushButton *applyButton = new QPushButton(tr("Apply")); applyButton = new QPushButton(tr("Apply"));
QPushButton *canselButton = new QPushButton(tr("&Cancel")); canselButton = new QPushButton(tr("&Cancel"));
QPushButton *okButton = new QPushButton(tr("&Ok")); okButton = new QPushButton(tr("&Ok"));
createIcons(); createIcons();
connect(contentsWidget, &QListWidget::currentItemChanged, this, &TapeConfigDialog::changePage); connect(contentsWidget, &QListWidget::currentItemChanged, this, &TapeConfigDialog::changePage);

View File

@ -114,9 +114,12 @@ QString TMainWindow::CurrentFile() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RetranslateTable() void TMainWindow::RetranslateTable()
{ {
const int row = ui->tableWidget->currentRow(); if (m != nullptr)
RefreshTable(); {
ui->tableWidget->selectRow(row); const int row = ui->tableWidget->currentRow();
RefreshTable();
ui->tableWidget->selectRow(row);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1356,25 +1359,43 @@ void TMainWindow::InitWindow()
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + " " + ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + " " +
VDomDocument::UnitsToStr(m->MUnit(), true)); VDomDocument::UnitsToStr(m->MUnit(), true));
// Because Qt Designer doesn't know about our deleting we will create empty objects for correct
// working the retranslation UI
// Tab Measurements // Tab Measurements
delete ui->labelFormula;
delete ui->horizontalLayoutValue; delete ui->horizontalLayoutValue;
delete ui->plainTextEditFormula; delete ui->plainTextEditFormula;
delete ui->pushButtonGrow;
delete ui->toolButtonExpr; delete ui->toolButtonExpr;
delete ui->labelFormula;
ui->labelFormula = new QLabel(this);
delete ui->pushButtonGrow;
ui->pushButtonGrow = new QPushButton(this);
// Tab Information // Tab Information
delete ui->labelGivenName;
delete ui->lineEditGivenName; delete ui->lineEditGivenName;
delete ui->labelFamilyName;
delete ui->lineEditFamilyName; delete ui->lineEditFamilyName;
delete ui->labelBirthDate;
delete ui->dateEditBirthDate;
delete ui->labelSex;
delete ui->comboBoxSex; delete ui->comboBoxSex;
delete ui->labelEmail;
delete ui->lineEditEmail; delete ui->lineEditEmail;
delete ui->labelGivenName;
ui->labelGivenName = new QLabel(this);
delete ui->labelFamilyName;
ui->labelFamilyName = new QLabel(this);
delete ui->labelBirthDate;
ui->labelBirthDate = new QLabel(this);
delete ui->dateEditBirthDate;
ui->dateEditBirthDate = new QDateEdit(this);
delete ui->labelSex;
ui->labelSex = new QLabel(this);
delete ui->labelEmail;
ui->labelEmail = new QLabel(this);
const QStringList listHeights = VMeasurement::WholeListHeights(mUnit); const QStringList listHeights = VMeasurement::WholeListHeights(mUnit);
const QStringList listSizes = VMeasurement::WholeListSizes(mUnit); const QStringList listSizes = VMeasurement::WholeListSizes(mUnit);
@ -1411,18 +1432,31 @@ void TMainWindow::InitWindow()
ui->lineEditEmail->setEnabled(true); ui->lineEditEmail->setEnabled(true);
// Tab Measurements // Tab Measurements
delete ui->labelBaseValue;
delete ui->doubleSpinBoxBaseValue; delete ui->doubleSpinBoxBaseValue;
delete ui->labelInSizes;
delete ui->doubleSpinBoxInSizes; delete ui->doubleSpinBoxInSizes;
delete ui->labelInHeights;
delete ui->doubleSpinBoxInHeights; delete ui->doubleSpinBoxInHeights;
delete ui->labelBaseValue;
ui->labelBaseValue = new QLabel(this);
delete ui->labelInSizes;
ui->labelInSizes = new QLabel(this);
delete ui->labelInHeights;
ui->labelInHeights = new QLabel(this);
// Tab Information // Tab Information
delete ui->labelBaseSize; delete ui->labelBaseSize;
ui->labelBaseSize = new QLabel(this);
delete ui->labelBaseSizeValue; delete ui->labelBaseSizeValue;
ui->labelBaseSizeValue = new QLabel(this);
delete ui->labelBaseHeight; delete ui->labelBaseHeight;
ui->labelBaseHeight = new QLabel(this);
delete ui->labelBaseHeightValue; delete ui->labelBaseHeightValue;
ui->labelBaseHeightValue = new QLabel(this);
ui->lineEditGivenName->setText(m->GivenName()); ui->lineEditGivenName->setText(m->GivenName());
ui->lineEditFamilyName->setText(m->FamilyName()); ui->lineEditFamilyName->setText(m->FamilyName());