Qt: optimize log viewer file loading

This commit is contained in:
Megamouse 2022-12-19 22:20:58 +01:00
parent a9ee9a69a4
commit 8ac9968096
2 changed files with 6 additions and 11 deletions

View File

@ -224,9 +224,8 @@ void log_viewer::show_log()
m_gui_settings->SetValue(gui::fd_log_viewer, m_path_last);
QTextStream stream(&file);
QString text = stream.readAll();
text.replace('\0', '0');
set_text_and_keep_position(text);
m_full_log = stream.readAll();
m_full_log.replace('\0', '0');
file.close();
}
else
@ -252,12 +251,8 @@ void log_viewer::filter_log()
{
if (m_full_log.isEmpty())
{
m_full_log = m_log_text->toPlainText();
if (m_full_log.isEmpty())
{
return;
}
set_text_and_keep_position(m_full_log);
return;
}
m_log_text->setPlainText(tr("Filtering..."));

View File

@ -15,7 +15,7 @@ void Highlighter::addRule(const QString &pattern, const QBrush &brush)
void Highlighter::highlightBlock(const QString &text)
{
for (const HighlightingRule &rule : highlightingRules)
for (const HighlightingRule& rule : highlightingRules)
{
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
while (matchIterator.hasNext())
@ -168,7 +168,7 @@ GlslHighlighter::GlslHighlighter(QTextDocument *parent) : Highlighter(parent)
<< "r16_snorm" << "r32ui"
<< "r8_snorm" << "r16ui";
for (const QString &pattern : keywordPatterns)
for (const QString& pattern : keywordPatterns)
addRule("\\b" + pattern + "\\b", Qt::darkBlue); // normal words like: soka, nani, or gomen
addRule("\\bGL_(?:[A-Z]|_)+\\b", Qt::darkMagenta); // constants like: GL_OMAE_WA_MOU_SHINDEIRU