Fixed Tape crash.

(grafted from 47b3aaf84786a338bc7c31284bef0bd5017a0c67)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-06-19 20:31:24 +03:00
parent 458d7be6b2
commit ed6c72bda9
2 changed files with 40 additions and 56 deletions

View File

@ -104,7 +104,8 @@ TMainWindow::TMainWindow(QWidget *parent)
dockDiagramVisible(true), dockDiagramVisible(true),
isInitialized(false), isInitialized(false),
recentFileActs(), recentFileActs(),
separatorAct(nullptr) separatorAct(nullptr),
hackedWidgets()
{ {
ui->setupUi(this); ui->setupUi(this);
@ -1869,39 +1870,23 @@ void TMainWindow::InitWindow()
// Because Qt Designer doesn't know about our deleting we will create empty objects for correct // Because Qt Designer doesn't know about our deleting we will create empty objects for correct
// working the retranslation UI // working the retranslation UI
// Tab Measurements // Tab Measurements
delete ui->horizontalLayoutValue; HackWidget(&ui->horizontalLayoutValue);
delete ui->plainTextEditFormula; HackWidget(&ui->plainTextEditFormula);
delete ui->toolButtonExpr; HackWidget(&ui->toolButtonExpr);
HackWidget(&ui->labelFormula);
delete ui->labelFormula; HackWidget(&ui->pushButtonGrow);
ui->labelFormula = new QLabel(this);
delete ui->pushButtonGrow;
ui->pushButtonGrow = new QPushButton(this);
// Tab Information // Tab Information
delete ui->lineEditGivenName; HackWidget(&ui->lineEditGivenName);
delete ui->lineEditFamilyName; HackWidget(&ui->lineEditFamilyName);
delete ui->comboBoxGender; HackWidget(&ui->comboBoxGender);
delete ui->lineEditEmail; HackWidget(&ui->lineEditEmail);
HackWidget(&ui->labelGivenName);
delete ui->labelGivenName; HackWidget(&ui->labelFamilyName);
ui->labelGivenName = new QLabel(this); HackWidget(&ui->labelBirthDate);
HackWidget(&ui->dateEditBirthDate);
delete ui->labelFamilyName; HackWidget(&ui->labelGender);
ui->labelFamilyName = new QLabel(this); HackWidget(&ui->labelEmail);
delete ui->labelBirthDate;
ui->labelBirthDate = new QLabel(this);
delete ui->dateEditBirthDate;
ui->dateEditBirthDate = new QDateEdit(this);
delete ui->labelGender;
ui->labelGender = 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);
@ -1941,31 +1926,18 @@ void TMainWindow::InitWindow()
ui->lineEditEmail->setEnabled(true); ui->lineEditEmail->setEnabled(true);
// Tab Measurements // Tab Measurements
delete ui->doubleSpinBoxBaseValue; HackWidget(&ui->doubleSpinBoxBaseValue);
delete ui->doubleSpinBoxInSizes; HackWidget(&ui->doubleSpinBoxInSizes);
delete ui->doubleSpinBoxInHeights; HackWidget(&ui->doubleSpinBoxInHeights);
HackWidget(&ui->labelBaseValue);
delete ui->labelBaseValue; HackWidget(&ui->labelInSizes);
ui->labelBaseValue = new QLabel(this); HackWidget(&ui->labelInHeights);
delete ui->labelInSizes;
ui->labelInSizes = new QLabel(this);
delete ui->labelInHeights;
ui->labelInHeights = new QLabel(this);
// Tab Information // Tab Information
delete ui->labelBaseSize; HackWidget(&ui->labelBaseSize);
ui->labelBaseSize = new QLabel(this); HackWidget(&ui->labelBaseSizeValue);
HackWidget(&ui->labelBaseHeight);
delete ui->labelBaseSizeValue; HackWidget(&ui->labelBaseHeightValue);
ui->labelBaseSizeValue = new QLabel(this);
delete ui->labelBaseHeight;
ui->labelBaseHeight = new QLabel(this);
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());
@ -3003,3 +2975,12 @@ void TMainWindow::InitGender(QComboBox *gender)
gender->addItem(tr("male", "gender"), QVariant(static_cast<int>(GenderType::Male))); gender->addItem(tr("male", "gender"), QVariant(static_cast<int>(GenderType::Male)));
gender->addItem(tr("female", "gender"), QVariant(static_cast<int>(GenderType::Female))); gender->addItem(tr("female", "gender"), QVariant(static_cast<int>(GenderType::Female)));
} }
//---------------------------------------------------------------------------------------------------------------------
template <class T>
void TMainWindow::HackWidget(T **widget)
{
delete *widget;
*widget = new T();
hackedWidgets.append(*widget);
}

View File

@ -153,7 +153,7 @@ private:
enum { MaxRecentFiles = 5 }; enum { MaxRecentFiles = 5 };
QAction *recentFileActs[MaxRecentFiles]; QAction *recentFileActs[MaxRecentFiles];
QAction *separatorAct; QAction *separatorAct;
QVector<QObject *> hackedWidgets;
void SetupMenu(); void SetupMenu();
void InitWindow(); void InitWindow();
@ -205,6 +205,9 @@ private:
void CreateWindowMenu(QMenu *menu); void CreateWindowMenu(QMenu *menu);
bool IgnoreLocking(int error, const QString &path); bool IgnoreLocking(int error, const QString &path);
template <class T>
void HackWidget(T **widget);
}; };
#endif // TMAINWINDOW_H #endif // TMAINWINDOW_H