mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
Fix parsing of new types from C (#3068)
In the TypesWidget, right-click+Load New Types was opening the dialog for editing an existing type instead of creating a new one. This would either result in an error (for atomic types) or the old type being deleted on success.
This commit is contained in:
parent
ad82407c2c
commit
3d49c4b65a
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user