Search code examples
qtmarkerscintillaqscintilla

Scintilla (QScintilla) 3rd marker define fails


In my class I attempt to define 3 markers, one for errors, one for warnings, and one for breakpoints. This worked well when I was only attempting to define 2 markers, but for some reason the third of these markers doesn't appear when added to a line. If you switch the ordering of the definitions, it is always the third one that fails to appear when markerAdd() is called. The pixmaps are valid, and Scintilla's return values appear to be correct for both defining and adding markers. This is more of a general Scintilla question rather than a QScintilla question I believe, because QScintilla simply does some checks before calling the underlying scintilla code. I have no idea where to even begin in debugging this code. If anyone can shed some light on this, whether it is a known scintilla quirk or it is my fault, I would be eternally grateful.

m_errorIndicator = ui_editor->markerDefine(QPixmap(":/sourcefile/icon_set/icons/bullet_red.png"));
m_breakIndicator = ui_editor->markerDefine(QPixmap(":/sourcefile/icon_set/icons/bullet_black.png"));
m_warningIndicator = ui_editor->markerDefine(QPixmap(":/sourcefile/icon_set/icons/bullet_yellow.png"));

void SourceFile::on_actionAddBreakpoint_triggered()
{
    qWarning() << "Added breakpoint to " << m_currentLine;
    qWarning() << ui_editor->markerAdd(m_currentLine, m_breakIndicator);
    m_breakpoints.append(m_currentLine);

}

void SourceFile::on_actionRemoveBreakpoint_triggered()
{
    ui_editor->markerDelete(m_currentLine, m_breakIndicator);
    m_breakpoints.removeAll(m_currentLine);
}


void SourceFile::clearProblems()
{
    ui_editor->markerDeleteAll(m_errorIndicator);
    ui_editor->markerDeleteAll(m_warningIndicator);
}

void SourceFile::markProblems(const QStringList& errors, const QStringList& warnings)
{
    foreach(const QString& error, errors) {
        int line = error.section(":", 1, 1).toInt();
        if(--line < 0) continue;
        ui_editor->markerAdd(line, m_errorIndicator);
    }
    foreach(const QString& warning, warnings) {
        int line = warning.section(":", 1, 1).toInt();
        if(--line < 0) continue;
        ui_editor->markerAdd(line, m_warningIndicator);
    }
}

There should be a yellow bullet next to the printf statement. If the warning and breakpoint definitions are switched, the yellow bullet will show up and the black bullet will disappear.


Solution

  • Aha! After days of looking, I finally found the problem.

        ui_editor->setMarginMarkerMask(1, m_breakpointMarker);
    

    Was being called in a setup method, which was causing funky behavior. Removing this fixed everything.