Skip to content

Commit

Permalink
Remove Qt4 code in Global/ and Engine/
Browse files Browse the repository at this point in the history
  • Loading branch information
acolwell committed Mar 19, 2024
1 parent cf270b6 commit 4248f6a
Show file tree
Hide file tree
Showing 22 changed files with 19 additions and 631 deletions.
27 changes: 0 additions & 27 deletions Engine/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@

#include "AppManagerPrivate.h" // include breakpad after Engine, because it includes /usr/include/AssertMacros.h on OS X which defines a check(x) macro, which conflicts with boost

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_DECLARE_METATYPE(QAbstractSocket::SocketState)
#endif

NATRON_NAMESPACE_ENTER

AppManager* AppManager::_instance = 0;
Expand Down Expand Up @@ -326,14 +322,6 @@ AppManager::loadFromArgs(const CLArgs& cl)
#endif
#endif

// Ensure Qt knows C-strings are UTF-8 before creating the QApplication for argv
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
// be forward compatible: source code is UTF-8, and Qt5 assumes UTF-8 by default
QTextCodec::setCodecForCStrings( QTextCodec::codecForName("UTF-8") );
QTextCodec::setCodecForTr( QTextCodec::codecForName("UTF-8") );
#endif


// This needs to be done BEFORE creating qApp because
// on Linux, X11 will create a context that would corrupt
// the XUniqueContext created by Qt
Expand Down Expand Up @@ -2036,18 +2024,10 @@ AppManager::registerPlugin(const QString& resourcesPath,
int minor,
bool isDeprecated)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QRecursiveMutex* pluginMutex = nullptr;
#else
QMutex* pluginMutex = 0;
#endif

if (mustCreateMutex) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
pluginMutex = new QRecursiveMutex();
#else
pluginMutex = new QMutex(QMutex::Recursive);
#endif
}
Plugin* plugin = new Plugin(binary, resourcesPath, pluginID, pluginLabel, pluginIconPath, groupIconPath, groups, pluginMutex, major, minor,
isReader, isWriter, isDeprecated);
Expand Down Expand Up @@ -2529,9 +2509,6 @@ AppManager::registerEngineMetaTypes() const
qRegisterMetaType<ViewSpec>("ViewSpec");
qRegisterMetaType<NodePtr>("NodePtr");
qRegisterMetaType<std::list<double> >("std::list<double>");
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
qRegisterMetaType<QAbstractSocket::SocketState>("SocketState");
#endif
}

void
Expand Down Expand Up @@ -3035,11 +3012,7 @@ AppManager::initPython()
}
// Set QT_API for QtPy
// https://github.com/spyder-ide/qtpy
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
qputenv("QT_API", "pyside");
#else
qputenv("QT_API", "pyside2");
#endif
} // AppManager::initPython

void
Expand Down
9 changes: 2 additions & 7 deletions Engine/AppManagerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,8 @@ AppManagerPrivate::AppManagerPrivate()

runningThreadsCount = 0;

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && defined(__NATRON_LINUX__)
#if defined(__NATRON_LINUX__)
onWayland = qEnvironmentVariableIsSet("WAYLAND_DISPLAY") && !qEnvironmentVariableIsSet("NATRON_DISABLE_WAYLAND");
#else
onWayland = false;
#endif
}

Expand Down Expand Up @@ -607,13 +605,10 @@ AppManagerPrivate::cleanUpCacheDiskStructure(const QString & cachePath, bool isT

QDir cacheFolder(cachePath);

# if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QtCompat::removeRecursively(cachePath);
# else
if ( cacheFolder.exists() ) {
cacheFolder.removeRecursively();
}
#endif

if ( !cacheFolder.exists() ) {
bool success = cacheFolder.mkpath( QChar::fromLatin1('.') );
if (!success) {
Expand Down
15 changes: 1 addition & 14 deletions Engine/CurvePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
#include "Global/Macros.h"

#include <QtCore/QMutex>
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
#include <QtCore/QRecursiveMutex>
#endif

#include "Engine/Variant.h"
#include "Engine/Knob.h"
Expand Down Expand Up @@ -66,11 +64,8 @@ struct CurvePrivate
CurveTypeEnum type;
double xMin, xMax;
double yMin, yMax;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
mutable QRecursiveMutex _lock;
#else
mutable QMutex _lock; //< the plug-ins can call getValueAt at any moment and we must make sure the user is not playing around
#endif

bool isParametric;
bool isPeriodic;

Expand All @@ -86,22 +81,14 @@ struct CurvePrivate
, xMax(std::numeric_limits<double>::infinity())
, yMin(-std::numeric_limits<double>::infinity())
, yMax(std::numeric_limits<double>::infinity())
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, _lock()
#else
, _lock(QMutex::Recursive)
#endif
, isParametric(false)
, isPeriodic(false)
{
}

CurvePrivate(const CurvePrivate & other)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
: _lock()
#else
: _lock(QMutex::Recursive)
#endif
{
*this = other;
}
Expand Down
8 changes: 0 additions & 8 deletions Engine/EffectInstancePrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,7 @@ EffectInstance::Implementation::Implementation(EffectInstance* publicInterface)
, metadata()
, runningClipPreferences(false)
, overlaysViewport(0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, attachedContextsMutex()
#else
, attachedContextsMutex(QMutex::Recursive)
#endif
, attachedContexts()
, mainInstance(0)
, isDoingInstanceSafeRender(false)
Expand Down Expand Up @@ -457,11 +453,7 @@ EffectInstance::Implementation::Implementation(const Implementation& other)
, metadata(other.metadata)
, runningClipPreferences(other.runningClipPreferences)
, overlaysViewport(other.overlaysViewport)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, attachedContextsMutex()
#else
, attachedContextsMutex(QMutex::Recursive)
#endif
, attachedContexts()
, mainInstance(other._publicInterface)
, isDoingInstanceSafeRender(false)
Expand Down
7 changes: 1 addition & 6 deletions Engine/EffectInstancePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QWaitCondition>
#include <QtCore/QMutex>
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
#include <QtCore/QRecursiveMutex>
#endif

#include "Global/GlobalDefines.h"

Expand Down Expand Up @@ -227,11 +225,8 @@ class EffectInstance::Implementation

// set during interact actions on main-thread
OverlaySupport* overlaysViewport;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
mutable QRecursiveMutex attachedContextsMutex;
#else
mutable QMutex attachedContextsMutex;
#endif

// A list of context that are currently attached (i.e attachOpenGLContext() has been called on them but not yet dettachOpenGLContext).
// If a plug-in returns false to supportsConcurrentOpenGLRenders() then whenever trying to attach a context, we take a lock in attachOpenGLContext
// that is released in dettachOpenGLContext so that there can only be a single attached OpenGL context at any time.
Expand Down
4 changes: 0 additions & 4 deletions Engine/FileSystemModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,11 +769,7 @@ Qt::ItemFlags
FileSystemModel::flags(const QModelIndex &index) const
{
if ( !index.isValid() ) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
return Qt::ItemFlags();
#else
return 0;
#endif
}

// Our model is read only.
Expand Down
8 changes: 0 additions & 8 deletions Engine/Knob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4902,11 +4902,7 @@ struct KnobHolder::KnobHolderPrivate
, isDequeingValuesSet(false)
, paramsEditLevel(eMultipleParamsEditOff)
, paramsEditRecursionLevel(0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, evaluationBlockedMutex()
#else
, evaluationBlockedMutex(QMutex::Recursive)
#endif
, evaluationBlocked(0)
, canCurrentlySetValue(true)
, knobChanged()
Expand Down Expand Up @@ -4934,11 +4930,7 @@ struct KnobHolder::KnobHolderPrivate
, isDequeingValuesSet(other.isDequeingValuesSet)
, paramsEditLevel(other.paramsEditLevel)
, paramsEditRecursionLevel(other.paramsEditRecursionLevel)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, evaluationBlockedMutex()
#else
, evaluationBlockedMutex(QMutex::Recursive)
#endif
, evaluationBlocked(0)
, canCurrentlySetValue(other.canCurrentlySetValue)
, knobChanged()
Expand Down
17 changes: 3 additions & 14 deletions Engine/Knob.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
#include <QtCore/QMutex>
#include <QtCore/QString>
#include <QtCore/QCoreApplication>
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
#include <QtCore/QRecursiveMutex>
#endif

#include "Engine/Variant.h"
#include "Engine/AppManager.h" // for AppManager::createKnob
Expand Down Expand Up @@ -2245,11 +2243,8 @@ class Knob
typedef std::shared_ptr<QueuedSetValueAtTime> QueuedSetValueAtTimePtr;

///Here is all the stuff we couldn't get rid of the template parameter
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
mutable QRecursiveMutex _valueMutex;
#else
mutable QMutex _valueMutex; //< protects _values & _guiValues & _defaultValues & ExprResults
#endif

std::vector<T> _values, _guiValues;

struct DefaultValue
Expand All @@ -2263,19 +2258,13 @@ class Knob
//Only for double and int
mutable QReadWriteLock _minMaxMutex;
std::vector<T> _minimums, _maximums, _displayMins, _displayMaxs;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
mutable QRecursiveMutex _setValuesQueueMutex;
#else
mutable QMutex _setValuesQueueMutex;
#endif

std::list<std::shared_ptr<QueuedSetValue> > _setValuesQueue;

///this flag is to avoid recursive setValue calls
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
mutable QRecursiveMutex _setValueRecursionLevelMutex;
#else
mutable QMutex _setValueRecursionLevelMutex;
#endif

int _setValueRecursionLevel;
};

Expand Down
12 changes: 0 additions & 12 deletions Engine/KnobImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,19 @@ Knob<T>::Knob(KnobHolder* holder,
int dimension,
bool declaredByPlugin )
: KnobHelper(holder, description, dimension, declaredByPlugin)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, _valueMutex()
#else
, _valueMutex(QMutex::Recursive)
#endif
, _values(dimension)
, _guiValues(dimension)
, _defaultValues(dimension)
, _exprRes(dimension)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, _minMaxMutex()
#else
, _minMaxMutex(QReadWriteLock::Recursive)
#endif
, _minimums(dimension)
, _maximums(dimension)
, _displayMins(dimension)
, _displayMaxs(dimension)
, _setValuesQueueMutex()
, _setValuesQueue()
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, _setValueRecursionLevelMutex()
#else
, _setValueRecursionLevelMutex(QMutex::Recursive)
#endif
, _setValueRecursionLevel(0)
{
initMinMax();
Expand Down
9 changes: 1 addition & 8 deletions Engine/NodeGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,11 +1055,8 @@ NodeCollection::getParallelRenderArgs(std::map<NodePtr, ParallelRenderArgsPtr>&

struct NodeGroupPrivate
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
mutable QRecursiveMutex nodesLock;
#else
mutable QMutex nodesLock; // protects inputs & outputs
#endif

std::vector<NodeWPtr> inputs, guiInputs;
NodesWList outputs, guiOutputs;
bool isDeactivatingGroup;
Expand All @@ -1068,11 +1065,7 @@ struct NodeGroupPrivate
KnobButtonPtr exportAsTemplate, convertToGroup;

NodeGroupPrivate()
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
: nodesLock()
#else
: nodesLock(QMutex::Recursive)
#endif
, inputs()
, guiInputs()
, outputs()
Expand Down
4 changes: 0 additions & 4 deletions Engine/NodePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ struct Node::Implementation
, mustQuitPreview(0)
, mustQuitPreviewMutex()
, mustQuitPreviewCond()
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
, renderInstancesSharedMutex()
#else
, renderInstancesSharedMutex(QMutex::Recursive)
#endif
, knobsAge(0)
, knobsAgeMutex()
, masterNodeMutex()
Expand Down
10 changes: 2 additions & 8 deletions Engine/OfxHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,12 +1122,9 @@ OfxHost::clearPluginsLoadedCache()
if ( QFile::exists(oldOfxCache) ) {
QFile::remove(oldOfxCache);
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QtCompat::removeRecursively( getOFXCacheDirPath() );
#else

QDir OFXCacheDir( getOFXCacheDirPath() );
OFXCacheDir.removeRecursively();
#endif
}

void
Expand Down Expand Up @@ -1535,11 +1532,8 @@ OfxHost::mutexCreate(OfxMutexHandle *mutex,

// suite functions should not throw
try {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QRecursiveMutex* m = new QRecursiveMutex();
#else
QMutex* m = new QMutex(QMutex::Recursive);
#endif

for (int i = 0; i < lockCount; ++i) {
m->lock();
}
Expand Down
4 changes: 0 additions & 4 deletions Engine/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ Plugin::getGrouping() const
return _grouping;
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QRecursiveMutex*
#else
QMutex*
#endif
Plugin::getPluginLock() const
{
return _lock;
Expand Down
Loading

0 comments on commit 4248f6a

Please sign in to comment.