Skip to content

Commit c1b0a9d

Browse files
committed
GUI: fix highlight_by_blocknum doesn't work after machine reload
1 parent 6af4d88 commit c1b0a9d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/gui/mainwindow/mainwindow.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,13 @@ void MainWindow::create_core(
256256
bool keep_memory) {
257257
// Create machine
258258
auto *new_machine = new machine::Machine(config, true, load_executable);
259-
260259
if (keep_memory && (machine != nullptr)) {
261260
new_machine->memory_rw()->reset(*machine->memory());
261+
*new_machine->address_to_blocknum_rw() = *machine->address_to_blocknum();
262262
}
263263

264264
// Remove old machine
265265
machine.reset(new_machine);
266-
267266
// Create machine view
268267
auto focused_index = central_widget_tabs->currentIndex();
269268
corescene.reset();
@@ -310,6 +309,7 @@ void MainWindow::create_core(
310309
connect(
311310
machine->core(), &machine::Core::stop_on_exception_reached, machine.data(),
312311
&machine::Machine::pause);
312+
connect(machine.data(), &machine::Machine::highlight_by_blocknum, this, &MainWindow::handle_highlight_by_blocknum);
313313

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

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

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

770-
connect(
771-
machine.data(), &machine::Machine::highlight_by_blocknum, editor,
772-
&SrcEditor::highlightBlock);
771+
connect(this, &MainWindow::highlight_by_blocknum, editor, &SrcEditor::highlightBlock);
773772

774773
if (error_occured) { show_messages(); }
775774
}

src/gui/mainwindow/mainwindow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class MainWindow : public QMainWindow {
5757
QString text,
5858
QString hint);
5959
void clear_messages();
60+
void highlight_by_blocknum(int blocknum);
6061

6162
public slots:
6263
// Actions signals
@@ -111,6 +112,9 @@ public slots:
111112
int column,
112113
const QString &text,
113114
const QString &hint);
115+
void handle_highlight_by_blocknum(int blocknum) {
116+
emit highlight_by_blocknum(blocknum);
117+
}
114118

115119
protected:
116120
void closeEvent(QCloseEvent *cancel) override;

0 commit comments

Comments
 (0)