0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 21:13:04 +02:00
obs-studio/UI/log-viewer.hpp
Matt Gajownik 0e57a7beef UI: Fix performance issues with the Log Viewer
This commit includes two big changes, alongside other smaller tweaks.

1) Update the internal QTextDocument of the text component directly
2) Use QPlainTextEdit, which supports HTML & is designed for long text
3) Use QString's arg function for formatting strings

Fix 1 significantly improves realtime performance when adding lines
individually, to the point that the UI no longer freezes if the viewer
is open and the log is being spammed. It also improves initial launch
speed when there's a large amount of text already in the file.
Reference: https://stackoverflow.com/a/54501760/2763321

Fix 2 completely eliminates delay when opening the viewer, regardless
of how many lines are already in the log file. For a standard log
after OBS launch, this cuts opening time from about 2 seconds to half a
second. For anything longer than 1,000 lines, the UI no longer freezes,
and the viewer (& its contents) open within half a second.
Reference: https://stackoverflow.com/a/17466240/2763321
2022-02-26 15:03:35 -08:00

24 lines
390 B
C++

#pragma once
#include <QDialog>
#include <QPlainTextEdit>
#include "obs-app.hpp"
class OBSLogViewer : public QDialog {
Q_OBJECT
QPointer<QPlainTextEdit> textArea;
void InitLog();
private slots:
void AddLine(int type, const QString &text);
void ClearText();
void ToggleShowStartup(bool checked);
void OpenFile();
public:
OBSLogViewer(QWidget *parent = 0);
~OBSLogViewer();
};