Core: Don't create Log Viewer just to close it

Change-Id: I92a724b0b1bc6a749fbd18f91494be0f2eff11d8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-10-30 08:11:11 +01:00
parent 79becbaeac
commit 936015b345

View File

@@ -1100,6 +1100,8 @@ void setCategoryColor(const QString &category, const QColor &color)
s_categoryColor.remove(category); s_categoryColor.remove(category);
} }
static bool wasLogViewerShown = false;
void LoggingViewer::showLoggingView() void LoggingViewer::showLoggingView()
{ {
LoggingViewManagerWidget *staticLogWidget = LoggingViewManagerWidget::instance(); LoggingViewManagerWidget *staticLogWidget = LoggingViewManagerWidget::instance();
@@ -1108,10 +1110,15 @@ void LoggingViewer::showLoggingView()
staticLogWidget->show(); staticLogWidget->show();
staticLogWidget->raise(); staticLogWidget->raise();
staticLogWidget->activateWindow(); staticLogWidget->activateWindow();
wasLogViewerShown = true;
} }
void LoggingViewer::hideLoggingView() void LoggingViewer::hideLoggingView()
{ {
if (!wasLogViewerShown)
return;
LoggingViewManagerWidget *staticLogWidget = LoggingViewManagerWidget::instance(); LoggingViewManagerWidget *staticLogWidget = LoggingViewManagerWidget::instance();
QTC_ASSERT(staticLogWidget, return); QTC_ASSERT(staticLogWidget, return);
staticLogWidget->close(); staticLogWidget->close();