Fixed crash.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-03 01:38:50 +03:00
parent 1d73547d28
commit f607e37168
2 changed files with 106 additions and 29 deletions

View File

@ -924,8 +924,6 @@ void TMainWindow::AddKnown()
ui->tableWidget->selectRow(currentRow);
MeasurementsWasSaved(false);
MFields(ui->tableWidget->rowCount() > 0);
}
delete dialog;
}
@ -1297,6 +1295,24 @@ void TMainWindow::SaveMBaseValue(double value)
}
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
QSharedPointer<VMeasurement> meash;
try
{
// Translate to internal look.
meash = data->GetVariable<VMeasurement>(nameField->data(Qt::UserRole).toString());
}
catch(const VExceptionBadId &e)
{
qCWarning(tMainWindow, "%s\n\n%s\n\n%s",
qUtf8Printable(tr("Can't find measurement '%1'.").arg(nameField->text())),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
return;
}
if (meash->IsCustom())
{
m->SetMBaseValue(nameField->data(Qt::UserRole).toString(), value);
MeasurementsWasSaved(false);
@ -1308,6 +1324,11 @@ void TMainWindow::SaveMBaseValue(double value)
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
}
else
{
qCWarning(tMainWindow, "%s", qUtf8Printable(tr("The base value of known measurement forbidden to change.")));
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMSizeIncrease(double value)
@ -1320,6 +1341,24 @@ void TMainWindow::SaveMSizeIncrease(double value)
}
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
QSharedPointer<VMeasurement> meash;
try
{
// Translate to internal look.
meash = data->GetVariable<VMeasurement>(nameField->data(Qt::UserRole).toString());
}
catch(const VExceptionBadId &e)
{
qCWarning(tMainWindow, "%s\n\n%s\n\n%s",
qUtf8Printable(tr("Can't find measurement '%1'.").arg(nameField->text())),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
return;
}
if (meash->IsCustom())
{
m->SetMSizeIncrease(nameField->data(Qt::UserRole).toString(), value);
MeasurementsWasSaved(false);
@ -1331,6 +1370,12 @@ void TMainWindow::SaveMSizeIncrease(double value)
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
}
else
{
qCWarning(tMainWindow, "%s",
qUtf8Printable(tr("The size increase value of known measurement forbidden to change.")));
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMHeightIncrease(double value)
@ -1343,6 +1388,24 @@ void TMainWindow::SaveMHeightIncrease(double value)
}
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
QSharedPointer<VMeasurement> meash;
try
{
// Translate to internal look.
meash = data->GetVariable<VMeasurement>(nameField->data(Qt::UserRole).toString());
}
catch(const VExceptionBadId &e)
{
qCWarning(tMainWindow, "%s\n\n%s\n\n%s",
qUtf8Printable(tr("Can't find measurement '%1'.").arg(nameField->text())),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
return;
}
if (meash->IsCustom())
{
m->SetMHeightIncrease(nameField->data(Qt::UserRole).toString(), value);
MeasurementsWasSaved(false);
@ -1352,6 +1415,12 @@ void TMainWindow::SaveMHeightIncrease(double value)
ui->tableWidget->selectRow(row);
}
else
{
qCWarning(tMainWindow, "%s",
qUtf8Printable(tr("The height increase value of known measurement forbidden to change.")));
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMDescription()
@ -1913,7 +1982,9 @@ void TMainWindow::RefreshTable()
}
else
{
AddCell(qApp->TrVars()->MToUser(meash->GetName()), currentRow, 0, Qt::AlignVCenter); // name
QTableWidgetItem *item = AddCell(qApp->TrVars()->MToUser(meash->GetName()), currentRow, 0,
Qt::AlignVCenter); // name
item->setData(Qt::UserRole, meash->GetName());
if (meash->IsCustom())
{
@ -2154,11 +2225,22 @@ void TMainWindow::MeasurementReadOnly(bool ro)
ui->lineEditName->setReadOnly(ro);
ui->plainTextEditDescription->setReadOnly(ro);
ui->lineEditFullName->setReadOnly(ro);
// Need to block signals for QLineEdit in readonly mode because it still emits
// QLineEdit::editingFinished signal.
ui->lineEditName->blockSignals(ro);
ui->lineEditFullName->blockSignals(ro);
}
if (mType == MeasurementsType::Individual)
{
ui->plainTextEditFormula->setReadOnly(ro);
// Need to block signals for QLineEdit in readonly mode because it still emits QLineEdit::editingFinished
// signal.
ui->lineEditGivenName->blockSignals(ro);
ui->lineEditFamilyName->blockSignals(ro);
ui->lineEditEmail->blockSignals(ro);
}
else
{
@ -2167,11 +2249,6 @@ void TMainWindow::MeasurementReadOnly(bool ro)
ui->doubleSpinBoxInHeights->setReadOnly(ro);
}
// Need to block signals for QLineEdit in readonly mode because it still emits QLineEdit::editingFinished signal.
ui->lineEditGivenName->blockSignals(ro);
ui->lineEditFamilyName->blockSignals(ro);
ui->lineEditEmail->blockSignals(ro);
Controls(); // Buttons remove, up, down
}

View File

@ -167,7 +167,7 @@ enum class GSizes : unsigned char { ALL,
{ \
if (!(cond)) \
{ \
qDebug("ASSERT: %s in %s (%s:%u)", \
qCritical("ASSERT: %s in %s (%s:%u)", \
#cond, Q_FUNC_INFO , __FILE__, __LINE__); \
debug_break(); \
} \