diff --git a/src/dialogs/TypesInteractionDialog.cpp b/src/dialogs/TypesInteractionDialog.cpp index eb2c2284..be363a30 100644 --- a/src/dialogs/TypesInteractionDialog.cpp +++ b/src/dialogs/TypesInteractionDialog.cpp @@ -22,7 +22,6 @@ TypesInteractionDialog::TypesInteractionDialog(QWidget *parent, bool readOnly) syntaxHighLighter = Config()->createSyntaxHighlighter(ui->plainTextEdit->document()); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); ui->plainTextEdit->setReadOnly(readOnly); - this->typeName = ""; } TypesInteractionDialog::~TypesInteractionDialog() {} @@ -64,10 +63,21 @@ void TypesInteractionDialog::done(int r) { if (r == QDialog::Accepted) { RzCoreLocked core(Core()); - bool edited = rz_type_db_edit_base_type( + bool success; + if (!typeName.isEmpty()) { + success = rz_type_db_edit_base_type( core->analysis->typedb, this->typeName.toUtf8().constData(), ui->plainTextEdit->toPlainText().toUtf8().constData()); - if (edited) { + } else { + char *error_msg = NULL; + success = rz_type_parse_string_stateless(core->analysis->typedb->parser, + ui->plainTextEdit->toPlainText().toUtf8().constData(), &error_msg) == 0; + if (error_msg) { + RZ_LOG_ERROR("%s\n", error_msg); + rz_mem_free(error_msg); + } + } + if (success) { emit newTypesLoaded(); QDialog::done(r); return; diff --git a/src/widgets/TypesWidget.cpp b/src/widgets/TypesWidget.cpp index ebdeace1..3891314e 100644 --- a/src/widgets/TypesWidget.cpp +++ b/src/widgets/TypesWidget.cpp @@ -293,7 +293,6 @@ void TypesWidget::on_actionLoad_New_Types_triggered() TypesInteractionDialog dialog(this); connect(&dialog, &TypesInteractionDialog::newTypesLoaded, this, &TypesWidget::refreshTypes); dialog.setWindowTitle(tr("Load New Types")); - dialog.setTypeName(t.type); dialog.exec(); }