Browse Source

UI: Do not always have log viewer loaded

This object should not always be created on startup. Instead, only load
it specifically when the user wants to load it.

This fixes a freeze some users were experiencing due to the text widget.
Unfortunately, it is not yet known how that freeze occurred with the log
viewer, so for the time being do not load the log viewer object unless
explicitly created.
jp9000 5 years ago
parent
commit
c0f19b95d5
4 changed files with 15 additions and 14 deletions
  1. 4 7
      UI/log-viewer.cpp
  2. 0 2
      UI/log-viewer.hpp
  3. 10 4
      UI/window-basic-main.cpp
  4. 1 1
      UI/window-basic-main.hpp

+ 4 - 7
UI/log-viewer.cpp

@@ -37,8 +37,11 @@ OBSLogViewer::OBSLogViewer(QWidget *parent) : QDialog(parent)
 	QPushButton *closeButton = new QPushButton(QTStr("Close"));
 	connect(closeButton, &QPushButton::clicked, this, &QDialog::hide);
 
+	bool showLogViewerOnStartup = config_get_bool(
+		App()->GlobalConfig(), "LogViewer", "ShowLogStartup");
+
 	QCheckBox *showStartup = new QCheckBox(QTStr("ShowOnStartup"));
-	showStartup->setChecked(ShowOnStartup());
+	showStartup->setChecked(showLogViewerOnStartup);
 	connect(showStartup, SIGNAL(toggled(bool)), this,
 		SLOT(ToggleShowStartup(bool)));
 
@@ -81,12 +84,6 @@ void OBSLogViewer::ToggleShowStartup(bool checked)
 			checked);
 }
 
-bool OBSLogViewer::ShowOnStartup()
-{
-	return config_get_bool(App()->GlobalConfig(), "LogViewer",
-			       "ShowLogStartup");
-}
-
 extern QPointer<OBSLogViewer> obsLogViewer;
 
 void OBSLogViewer::InitLog()

+ 0 - 2
UI/log-viewer.hpp

@@ -20,6 +20,4 @@ private slots:
 public:
 	OBSLogViewer(QWidget *parent = 0);
 	~OBSLogViewer();
-
-	bool ShowOnStartup();
 };

+ 10 - 4
UI/window-basic-main.cpp

@@ -193,9 +193,6 @@ extern void RegisterRestreamAuth();
 OBSBasic::OBSBasic(QWidget *parent)
 	: OBSMainWindow(parent), ui(new Ui::OBSBasic)
 {
-	/* setup log viewer */
-	logView = new OBSLogViewer();
-
 	qRegisterMetaTypeStreamOperators<SignalContainer<OBSScene>>(
 		"SignalContainer<OBSScene>");
 
@@ -1955,8 +1952,14 @@ void OBSBasic::OnFirstLoad()
 
 	Auth::Load();
 
-	if (logView && logView->ShowOnStartup())
+	bool showLogViewerOnStartup = config_get_bool(
+		App()->GlobalConfig(), "LogViewer", "ShowLogStartup");
+
+	if (showLogViewerOnStartup) {
+		if (!logView)
+			logView = new OBSLogViewer();
 		logView->show();
+	}
 }
 
 void OBSBasic::DeferredSysTrayLoad(int requeueCount)
@@ -5331,6 +5334,9 @@ void OBSBasic::on_actionUploadLastLog_triggered()
 
 void OBSBasic::on_actionViewCurrentLog_triggered()
 {
+	if (!logView)
+		logView = new OBSLogViewer();
+
 	if (!logView->isVisible()) {
 		logView->setVisible(true);
 	} else {

+ 1 - 1
UI/window-basic-main.hpp

@@ -214,7 +214,7 @@ private:
 	QPointer<QDockWidget> statsDock;
 	QPointer<OBSAbout> about;
 
-	OBSLogViewer *logView;
+	OBSLogViewer *logView = nullptr;
 
 	QPointer<QTimer> cpuUsageTimer;
 	QPointer<QTimer> diskFullTimer;