diff --git a/rpcs3/rpcs3qt/log_frame.cpp b/rpcs3/rpcs3qt/log_frame.cpp index d651c2623768..76cd124912c9 100644 --- a/rpcs3/rpcs3qt/log_frame.cpp +++ b/rpcs3/rpcs3qt/log_frame.cpp @@ -509,22 +509,25 @@ void log_frame::UpdateUI() const std::chrono::time_point tty_timeout = start + 4ms; const std::chrono::time_point log_timeout = start + 7ms; - // Check TTY logs - while (const u64 size = std::max(0, g_tty_size.load() - (m_tty_file ? m_tty_file.pos() : 0))) + // Check TTY logs (and try to complete pending work) + for (u64 size{}; !m_tty_buf_stream.view().empty() || (!size && (size = std::max(0, g_tty_size.load() - (m_tty_file ? m_tty_file.pos() : 0))));) { - std::string buf; - buf.resize(size); - buf.resize(m_tty_file.read(&buf.front(), buf.size())); + if (!m_tty_buf_stream.view().empty() || m_tty_act->isChecked()) + { + std::string buf; + buf.resize(size); + buf.resize(m_tty_file.read(&buf.front(), buf.size())); - // Ignore control characters and greater/equal to 0x80 - buf.erase(std::remove_if(buf.begin(), buf.end(), [](s8 c) { return c <= 0x8 || c == 0x7F || (c >= 0xE && c <= 0x1F); }), buf.end()); + // Ignore control characters and greater/equal to 0x80 + buf.erase(std::remove_if(buf.begin(), buf.end(), [](s8 c) { return c <= 0x8 || c == 0x7F || (c >= 0xE && c <= 0x1F); }), buf.end()); + + if (!m_tty_buf_stream.view().empty()) + { + m_tty_buf_stream.str(buf); + } - if (!buf.empty() && m_tty_act->isChecked()) - { - std::stringstream buf_stream; - buf_stream.str(buf); std::string buf_line; - while (std::getline(buf_stream, buf_line)) + while (std::getline(m_tty_buf_stream, buf_line)) { // save old scroll bar state QScrollBar* sb = m_tty->verticalScrollBar(); @@ -582,11 +585,22 @@ void log_frame::UpdateUI() // set scrollbar to max means auto-scroll sb->setValue(is_max ? sb->maximum() : sb_pos); + + // Limit processing time + if (steady_clock::now() >= tty_timeout) break; } - } - // Limit processing time - if (steady_clock::now() >= tty_timeout || buf.empty()) break; + if (size) + { + break; + } + } + else + { + // Advance in position without printing + m_tty_file.seek(size, fs::seek_cur); + break; + } } const auto font_start_tag = [](const QColor& color) -> const QString { return QStringLiteral(""); }; diff --git a/rpcs3/rpcs3qt/log_frame.h b/rpcs3/rpcs3qt/log_frame.h index 130f5df3184b..c326f820823c 100644 --- a/rpcs3/rpcs3qt/log_frame.h +++ b/rpcs3/rpcs3qt/log_frame.h @@ -7,6 +7,7 @@ #include "find_dialog.h" #include +#include #include #include @@ -54,6 +55,7 @@ private Q_SLOTS: std::string m_old_log_text; QString m_old_tty_text; QString m_log_text; + std::stringstream m_tty_buf_stream; usz m_log_counter{}; usz m_tty_counter{}; bool m_stack_log{};