Skip to content

Commit

Permalink
Do not display the "Loading project" splash screen on macOS 12+/Qt4
Browse files Browse the repository at this point in the history
fixes #712
  • Loading branch information
devernay committed Dec 17, 2021
1 parent 254aadf commit 172b1d1
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Engine/AppInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON

virtual void updateProjectLoadStatus(const QString& /*str*/) {}

virtual void closeLoadPRojectSplashScreen() {}
virtual void closeLoadProjectSplashScreen() {}

std::string getAppIDString() const;
const std::list<NodePtr>& getNodesBeingCreated() const;
Expand Down
2 changes: 1 addition & 1 deletion Engine/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class LoadProjectSplashScreen_RAII
AppInstancePtr a = app.lock();

if (a) {
a->closeLoadPRojectSplashScreen();
a->closeLoadProjectSplashScreen();
}
}
};
Expand Down
32 changes: 27 additions & 5 deletions Gui/GuiAppInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

#include "GuiAppInstance.h"

#if defined(__APPLE__) && QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <string.h>
#include <stdio.h>
#include <sys/sysctl.h>
#endif

#include <stdexcept>
#include <sstream> // stringstream

Expand Down Expand Up @@ -228,12 +234,10 @@ GuiAppInstance::aboutToQuit()
AppInstance::aboutToQuit();

_imp->_isClosing = true;
_imp->_gui->hide();
_imp->_gui->close();
//delete _imp->_gui;
_imp->_gui->deleteLater();



// Make sure all events are processed
qApp->processEvents();
// Make sure all deleteLater calls are reached
Expand Down Expand Up @@ -1011,6 +1015,23 @@ GuiAppInstance::declareCurrentAppVariable_Python()
void
GuiAppInstance::createLoadProjectSplashScreen(const QString& projectFile)
{
QCoreApplication::processEvents();
#if defined(__APPLE__) && QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
short int version_[3] = {0};
char str[256] = {0};
size_t size = sizeof(str);
int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0);
if (ret == 0) {
sscanf(str, "%hd.%hd.%hd", &version_[0], &version_[1], &version_[2]);
}
if (version_[0] >= 21) {
// On macOS 12 Monterey, Qt4 crashes the app when closing
// a window, including the splash screen.
// See: https://github.com/NatronGitHub/Natron/issues/712
// This is probably a Qt4 bug, so let us avoid the splash screen.
return;
}
#endif
if (_imp->loadProjectSplash) {
return;
}
Expand All @@ -1028,11 +1049,12 @@ GuiAppInstance::updateProjectLoadStatus(const QString& str)
}

void
GuiAppInstance::closeLoadPRojectSplashScreen()
GuiAppInstance::closeLoadProjectSplashScreen()
{
if (_imp->loadProjectSplash) {
_imp->loadProjectSplash->hide();
_imp->loadProjectSplash->close();
delete _imp->loadProjectSplash;
_imp->loadProjectSplash->deleteLater();
_imp->loadProjectSplash = 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Gui/GuiAppInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON
virtual void declareCurrentAppVariable_Python() OVERRIDE;
virtual void createLoadProjectSplashScreen(const QString& projectFile) OVERRIDE FINAL;
virtual void updateProjectLoadStatus(const QString& str) OVERRIDE FINAL;
virtual void closeLoadPRojectSplashScreen() OVERRIDE FINAL;
virtual void closeLoadProjectSplashScreen() OVERRIDE FINAL;
virtual void renderAllViewers(bool canAbort) OVERRIDE FINAL;
virtual void refreshAllPreviews() OVERRIDE FINAL;
virtual void abortAllViewers() OVERRIDE FINAL;
Expand Down
2 changes: 1 addition & 1 deletion Gui/GuiApplicationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ GuiApplicationManager::hideSplashScreen()
if (_imp->_splashScreen) {
_imp->_splashScreen->hide();
_imp->_splashScreen->close();
delete _imp->_splashScreen;
_imp->_splashScreen->deleteLater();
_imp->_splashScreen = 0;
}
}
Expand Down
18 changes: 8 additions & 10 deletions Gui/NodeGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4052,27 +4052,25 @@ GroupKnobDialog::GroupKnobDialog(Gui* gui,
refreshUserParamsGUI();
}

typedef boost::shared_ptr<GroupKnobDialog> GroupKnobDialogPtr;

void
NodeGui::showGroupKnobAsDialog(KnobGroup* group)
{
assert( QThread::currentThread() == qApp->thread() );
assert(group);
bool showDialog = group->getValue();
if (showDialog) {
assert(!_activeNodeCustomModalDialog);
GroupKnobDialogPtr dialog( new GroupKnobDialog(getDagGui()->getGui(), group) );
_activeNodeCustomModalDialog = dialog;
dialog->move( QCursor::pos() );
int accepted = dialog->exec();
_activeNodeCustomModalDialog = new GroupKnobDialog(getDagGui()->getGui(), group);
_activeNodeCustomModalDialog->move( QCursor::pos() );
int accepted = _activeNodeCustomModalDialog->exec();
Q_UNUSED(accepted);
// Notify dialog closed
group->onValueChanged(false, ViewSpec::all(), 0, eValueChangedReasonUserEdited, 0);
_activeNodeCustomModalDialog.reset();
} else {
_activeNodeCustomModalDialog->deleteLater();
_activeNodeCustomModalDialog = 0;
} else if (_activeNodeCustomModalDialog) {
_activeNodeCustomModalDialog->close();
_activeNodeCustomModalDialog.reset();
_activeNodeCustomModalDialog->deleteLater();
_activeNodeCustomModalDialog = 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Gui/NodeGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ public Q_SLOTS:
NodeGuiIndicatorPtr _passThroughIndicator;
NodeWPtr _identityInput;
bool identityStateSet;
NATRON_PYTHON_NAMESPACE::PyModalDialogPtr _activeNodeCustomModalDialog;
NATRON_PYTHON_NAMESPACE::PyModalDialog* _activeNodeCustomModalDialog;
};

NATRON_NAMESPACE_EXIT
Expand Down
1 change: 0 additions & 1 deletion Gui/ViewerTab10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ ViewerTab::~ViewerTab()
} else {
graph = gui->getNodeGraph();
}
assert(graph);
GuiAppInstancePtr app = gui->getApp();
if ( app && !app->isClosing() && graph && (graph->getLastSelectedViewer() == this) ) {
graph->setLastSelectedViewer(0);
Expand Down

0 comments on commit 172b1d1

Please sign in to comment.