Skip to content

Commit 74abd75

Browse files
trdthgjdupak
authored andcommitted
GUI: fix highlight_by_blocknum doesn't work after machine reload
1 parent bc9cf55 commit 74abd75

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
@@ -258,14 +258,13 @@ void MainWindow::create_core(
258258
bool keep_memory) {
259259
// Create machine
260260
auto *new_machine = new machine::Machine(config, true, load_executable);
261-
262261
if (keep_memory && (machine != nullptr)) {
263262
new_machine->memory_rw()->reset(*machine->memory());
263+
*new_machine->address_to_blocknum_rw() = *machine->address_to_blocknum();
264264
}
265265

266266
// Remove old machine
267267
machine.reset(new_machine);
268-
269268
// Create machine view
270269
auto focused_index = central_widget_tabs->currentIndex();
271270
corescene.reset();
@@ -312,6 +311,7 @@ void MainWindow::create_core(
312311
connect(
313312
machine->core(), &machine::Core::stop_on_exception_reached, machine.data(),
314313
&machine::Machine::pause);
314+
connect(machine.data(), &machine::Machine::highlight_by_blocknum, this, &MainWindow::handle_highlight_by_blocknum);
315315

316316
// Setup docks
317317
registers->connectToMachine(machine.data());
@@ -760,6 +760,7 @@ void MainWindow::compile_source() {
760760

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

763+
machine->address_to_blocknum_rw()->clear();
763764
sasm.setup(
764765
mem, &symtab, machine::Address(0x00000200), machine->core()->get_xlen(),
765766
machine->address_to_blocknum_rw());
@@ -771,9 +772,7 @@ void MainWindow::compile_source() {
771772
}
772773
if (!sasm.finish()) { error_occured = true; }
773774

774-
connect(
775-
machine.data(), &machine::Machine::highlight_by_blocknum, editor,
776-
&SrcEditor::highlightBlock);
775+
connect(this, &MainWindow::highlight_by_blocknum, editor, &SrcEditor::highlightBlock);
777776

778777
if (error_occured) { show_messages(); }
779778
}

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)