Skip to content

Commit

Permalink
GUI: fix highlight_by_blocknum doesn't work after machine reload
Browse files Browse the repository at this point in the history
  • Loading branch information
trdthg committed Jun 18, 2024
1 parent 6af4d88 commit c1b0a9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/gui/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,13 @@ void MainWindow::create_core(
bool keep_memory) {
// Create machine
auto *new_machine = new machine::Machine(config, true, load_executable);

if (keep_memory && (machine != nullptr)) {
new_machine->memory_rw()->reset(*machine->memory());
*new_machine->address_to_blocknum_rw() = *machine->address_to_blocknum();
}

// Remove old machine
machine.reset(new_machine);

// Create machine view
auto focused_index = central_widget_tabs->currentIndex();
corescene.reset();
Expand Down Expand Up @@ -310,6 +309,7 @@ void MainWindow::create_core(
connect(
machine->core(), &machine::Core::stop_on_exception_reached, machine.data(),
&machine::Machine::pause);
connect(machine.data(), &machine::Machine::highlight_by_blocknum, this, &MainWindow::handle_highlight_by_blocknum);

// Setup docks
registers->connectToMachine(machine.data());
Expand Down Expand Up @@ -756,6 +756,7 @@ void MainWindow::compile_source() {

connect(&sasm, &SimpleAsm::report_message, this, &MainWindow::report_message);

machine->address_to_blocknum_rw()->clear();
sasm.setup(
mem, &symtab, machine::Address(0x00000200), machine->core()->get_xlen(),
machine->address_to_blocknum_rw());
Expand All @@ -767,9 +768,7 @@ void MainWindow::compile_source() {
}
if (!sasm.finish()) { error_occured = true; }

connect(
machine.data(), &machine::Machine::highlight_by_blocknum, editor,
&SrcEditor::highlightBlock);
connect(this, &MainWindow::highlight_by_blocknum, editor, &SrcEditor::highlightBlock);

if (error_occured) { show_messages(); }
}
Expand Down
4 changes: 4 additions & 0 deletions src/gui/mainwindow/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MainWindow : public QMainWindow {
QString text,
QString hint);
void clear_messages();
void highlight_by_blocknum(int blocknum);

public slots:
// Actions signals
Expand Down Expand Up @@ -111,6 +112,9 @@ public slots:
int column,
const QString &text,
const QString &hint);
void handle_highlight_by_blocknum(int blocknum) {
emit highlight_by_blocknum(blocknum);
}

protected:
void closeEvent(QCloseEvent *cancel) override;
Expand Down

0 comments on commit c1b0a9d

Please sign in to comment.