From 1b6e9c1c79f72865da0afbc942fbf1e061a9b809 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 17 Jun 2020 03:00:00 +1000 Subject: [PATCH] viewer: moved nouveau to application launch rather than viewer init Viewer init was kind of too late since in many cases the sequence would start caching and crash the app before the user could even read the message. Moving to the startup makes it clearer from the beginning. --- app/widget/viewer/viewerdisplay.cpp | 31 ---------------------------- app/widget/viewer/viewerdisplay.h | 11 ---------- app/window/mainwindow/mainwindow.cpp | 30 +++++++++++++++++++++++++++ app/window/mainwindow/mainwindow.h | 6 ++++++ 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/app/widget/viewer/viewerdisplay.cpp b/app/widget/viewer/viewerdisplay.cpp index 420eaf423..943314ef7 100644 --- a/app/widget/viewer/viewerdisplay.cpp +++ b/app/widget/viewer/viewerdisplay.cpp @@ -38,10 +38,6 @@ OLIVE_NAMESPACE_ENTER -#ifdef Q_OS_LINUX -bool ViewerDisplayWidget::nouveau_check_done_ = false; -#endif - ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) : ManagedDisplayWidget(parent), signal_cursor_color_(false), @@ -199,21 +195,6 @@ void ViewerDisplayWidget::initializeGL() ManagedDisplayWidget::initializeGL(); connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ViewerDisplayWidget::ContextCleanup, Qt::DirectConnection); - -#ifdef Q_OS_LINUX - if (!nouveau_check_done_) { - const char* vendor = reinterpret_cast(context()->functions()->glGetString(GL_VENDOR)); - - if (!strcmp(vendor, "nouveau")) { - // Working with Qt widgets in this function segfaults, so we queue the messagebox for later - QMetaObject::invokeMethod(this, - "ShowNouveauWarning", - Qt::QueuedConnection); - } - - nouveau_check_done_ = true; - } -#endif } void ViewerDisplayWidget::paintGL() @@ -305,18 +286,6 @@ rational ViewerDisplayWidget::GetGizmoTime() return GetAdjustedTime(GetTimeTarget(), gizmos_, time_, NodeParam::kInput); } -#ifdef Q_OS_LINUX -void ViewerDisplayWidget::ShowNouveauWarning() -{ - QMessageBox::warning(this, - tr("Driver Warning"), - tr("Olive has detected your system is using the Nouveau graphics driver.\n\nThis driver is " - "known to have stability and performance issues with Olive. It is highly recommended " - "you install the proprietary NVIDIA driver before continuing to use Olive."), - QMessageBox::Ok); -} -#endif - void ViewerDisplayWidget::ContextCleanup() { makeCurrent(); diff --git a/app/widget/viewer/viewerdisplay.h b/app/widget/viewer/viewerdisplay.h index 5f18cc303..f8db608ef 100644 --- a/app/widget/viewer/viewerdisplay.h +++ b/app/widget/viewer/viewerdisplay.h @@ -160,10 +160,6 @@ private: */ QMatrix4x4 matrix_; -#ifdef Q_OS_LINUX - static bool nouveau_check_done_; -#endif - bool signal_cursor_color_; ViewerSafeMarginInfo safe_margin_; @@ -184,13 +180,6 @@ private slots: */ void ContextCleanup(); -#ifdef Q_OS_LINUX - /** - * @brief Shows warning messagebox if Nouveau is detected - */ - void ShowNouveauWarning(); -#endif - }; OLIVE_NAMESPACE_EXIT diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 31239436d..5e61cd1d6 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -415,6 +415,18 @@ void MainWindow::StatusBarDoubleClicked() task_man_panel_->raise(); } +#ifdef Q_OS_LINUX +void MainWindow::ShowNouveauWarning() +{ + QMessageBox::warning(this, + tr("Driver Warning"), + tr("Olive has detected your system is using the Nouveau graphics driver.\n\nThis driver is " + "known to have stability and performance issues with Olive. It is highly recommended " + "you install the proprietary NVIDIA driver before continuing to use Olive."), + QMessageBox::Ok); +} +#endif + void MainWindow::UpdateTitle() { if (Core::instance()->GetActiveProject()) { @@ -626,6 +638,24 @@ void MainWindow::SetDefaultLayout() Qt::Vertical); } +void MainWindow::showEvent(QShowEvent *e) +{ + QMainWindow::showEvent(e); + +#ifdef Q_OS_LINUX + // Check for nouveau since that driver really doesn't work with Olive + QOffscreenSurface surface; + surface.create(); + QOpenGLContext context; + context.create(); + context.makeCurrent(&surface); + const char* vendor = reinterpret_cast(context.functions()->glGetString(GL_VENDOR)); + if (!strcmp(vendor, "nouveau")) { + QMetaObject::invokeMethod(this, "ShowNouveauWarning", Qt::QueuedConnection); + } +#endif +} + template T *MainWindow::AppendPanelInternal(QList& list) { diff --git a/app/window/mainwindow/mainwindow.h b/app/window/mainwindow/mainwindow.h index 21a6d561c..f01f0524a 100644 --- a/app/window/mainwindow/mainwindow.h +++ b/app/window/mainwindow/mainwindow.h @@ -103,6 +103,8 @@ public slots: void SetDefaultLayout(); protected: + virtual void showEvent(QShowEvent* e) override; + virtual void closeEvent(QCloseEvent* e) override; #ifdef Q_OS_WINDOWS @@ -167,6 +169,10 @@ private slots: void StatusBarDoubleClicked(); +#ifdef Q_OS_LINUX + void ShowNouveauWarning(); +#endif + }; OLIVE_NAMESPACE_EXIT