Fixed Tape crash.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2016-06-19 20:26:45 +03:00
parent cdf3d76930
commit cfb836a573
2 changed files with 40 additions and 55 deletions

View File

@ -98,7 +98,8 @@ TMainWindow::TMainWindow(QWidget *parent)
labelPatternUnit(nullptr), labelPatternUnit(nullptr),
actionDockDiagram(nullptr), actionDockDiagram(nullptr),
dockDiagramVisible(false), dockDiagramVisible(false),
isInitialized(false) isInitialized(false),
hackedWidgets()
{ {
ui->setupUi(this); ui->setupUi(this);
@ -1773,39 +1774,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);
@ -1845,31 +1830,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());
@ -2894,3 +2866,12 @@ void TMainWindow::ShowInGraphicalShell()
#endif #endif
} }
//---------------------------------------------------------------------------------------------------------------------
template <class T>
void TMainWindow::HackWidget(T **widget)
{
delete *widget;
*widget = new T();
hackedWidgets.append(*widget);
}

View File

@ -152,6 +152,7 @@ private:
QAction *actionDockDiagram; QAction *actionDockDiagram;
bool dockDiagramVisible; bool dockDiagramVisible;
bool isInitialized; bool isInitialized;
QVector<QObject *> hackedWidgets;
void SetupMenu(); void SetupMenu();
void InitWindow(); void InitWindow();
@ -202,6 +203,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