A memory occurs within QPlainTextEdit::clear if extra selections has been set.
This is most possibly a bug, but seems to be fixed if we manually clear the
selections before we clear (and add new text) to the text edit.
MODIFY
src/edittab.cpp
src/edittab.cpp
@@ -84,8 +84,8 @@ void EditTab::updateProgramViewerHighlighting() {
}
void EditTab::emitProgramChanged() {
- updateProgramViewer();
emit programChanged(&m_activeProgram);
+ updateProgramViewer();
}
void EditTab::assemble() {
@@ -132,7 +132,6 @@ void EditTab::updateProgramViewer() {
void EditTab::enableEditor() {
connect(m_ui->assemblyedit, &CodeEditor::textChanged, this, &EditTab::assemble);
m_ui->editorStackedWidget->setCurrentIndex(0);
- clearAssemblyEditor();
}
void EditTab::disableEditor() {

MODIFY
src/programviewer.cpp
src/programviewer.cpp
@@ -46,8 +46,13 @@ void ProgramViewer::resizeEvent(QResizeEvent* e) {
void ProgramViewer::updateProgram(const Program& program, bool binary) {
m_labelAddrOffsetMap.clear();
- const auto text = binary ? Parser::getParser()->binarize(program, m_labelAddrOffsetMap)
+ const QString text = binary ? Parser::getParser()->binarize(program, m_labelAddrOffsetMap)
: Parser::getParser()->disassemble(program, m_labelAddrOffsetMap);
+
+ // A memory occurs within QPlainTextEdit::clear if extra selections has been set. This is most possibly a bug, but
+ // seems to be fixed if we manually clear the selections before we clear (and add new text) to the text edit.
+ setExtraSelections({});
+
setPlainText(text);
updateHighlightedAddresses();
}
@@ -169,6 +174,13 @@ QTextBlock ProgramViewer::blockForAddress(unsigned long addr) const {
long lineNumber = adjustedLineNumber;
auto low = m_labelAddrOffsetMap.lower_bound(lineNumber);
+
+ if (lineNumber < low->first && (low == m_labelAddrOffsetMap.begin())) {
+ // The line number is less that the position of the first offset block; block is directly inferred from
+ // linenumber.
+ return document()->findBlockByNumber(adjustedLineNumber);
+ }
+
auto high = low;
if (low != m_labelAddrOffsetMap.begin()) {
low = std::prev(m_labelAddrOffsetMap.lower_bound(lineNumber));

A memory occurs within QPlainTextEdit::clear if extra selections has been set.
This is most possibly a bug, but seems to be fixed if we manually clear the
selections before we clear (and add new text) to the text edit.