Skip to content

Commit

Permalink
Fix Qt6 build
Browse files Browse the repository at this point in the history
  • Loading branch information
YakoYakoYokuYoku committed Dec 20, 2024
1 parent 8f54ccd commit 876a222
Show file tree
Hide file tree
Showing 84 changed files with 586 additions and 60 deletions.
1 change: 0 additions & 1 deletion Engine/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QTextCodec>
#include <QCoreApplication>
#include <QSettings>
#include <QThreadPool>
Expand Down
12 changes: 12 additions & 0 deletions Engine/EffectInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4097,7 +4097,11 @@ EffectInstance::attachOpenGLContext_public(const OSGLContextPtr& glContext,
{
NON_RECURSIVE_ACTION();
bool concurrentGLRender = supportsConcurrentOpenGLRenders();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::unique_ptr<QMutexLocker<QRecursiveMutex>> locker;
#else
std::unique_ptr<QMutexLocker> locker;
#endif
if (concurrentGLRender) {
locker.reset( new QMutexLocker(&_imp->attachedContextsMutex) );
} else {
Expand Down Expand Up @@ -4131,7 +4135,11 @@ EffectInstance::attachOpenGLContext_public(const OSGLContextPtr& glContext,
void
EffectInstance::dettachAllOpenGLContexts()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMutexLocker<QRecursiveMutex> locker(&_imp->attachedContextsMutex);
#else
QMutexLocker locker(&_imp->attachedContextsMutex);
#endif

for (EffectInstance::OpenGLContextEffectsMap::iterator it = _imp->attachedContexts.begin(); it != _imp->attachedContexts.end(); ++it) {
OSGLContextPtr context = it->first.lock();
Expand All @@ -4158,7 +4166,11 @@ EffectInstance::dettachOpenGLContext_public(const OSGLContextPtr& glContext, con
{
NON_RECURSIVE_ACTION();
bool concurrentGLRender = supportsConcurrentOpenGLRenders();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::unique_ptr<QMutexLocker<QRecursiveMutex>> locker;
#else
std::unique_ptr<QMutexLocker> locker;
#endif
if (concurrentGLRender) {
locker.reset( new QMutexLocker(&_imp->attachedContextsMutex) );
}
Expand Down
13 changes: 13 additions & 0 deletions Engine/EffectInstanceRenderRoI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,12 @@ EffectInstance::renderRoI(const RenderRoIArgs & args,
///locks belongs to an instance)


#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::unique_ptr<QMutexLocker<QMutex>> locker;
std::unique_ptr<QMutexLocker<QRecursiveMutex>> recursiveLocker;
#else
std::unique_ptr<QMutexLocker> locker;
#endif


EffectInstancePtr renderInstance;
Expand All @@ -1535,11 +1540,19 @@ EffectInstance::renderRoI(const RenderRoIArgs & args,
assert(renderInstance);

if (safety == eRenderSafetyInstanceSafe) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
locker.reset( new QMutexLocker<QMutex>( &getNode()->getRenderInstancesSharedMutex() ) );
#else
locker.reset( new QMutexLocker( &getNode()->getRenderInstancesSharedMutex() ) );
#endif
} else if (safety == eRenderSafetyUnsafe) {
const Plugin* p = getNode()->getPlugin();
assert(p);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
recursiveLocker.reset( new QMutexLocker<QRecursiveMutex>( p->getPluginLock() ) );
#else
locker.reset( new QMutexLocker( p->getPluginLock() ) );
#endif
} else {
// no need to lock
Q_UNUSED(locker);
Expand Down
8 changes: 8 additions & 0 deletions Engine/EngineFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include "Global/Macros.h"

#include <QtGlobal>

#include <memory>
#include <list>
#include <vector>
Expand Down Expand Up @@ -61,7 +63,13 @@ class QNetworkRequest;
class QProcess;
class QSettings;
class QString;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
template<typename T> class QList;
template<typename T> using QVector = QList<T>;
using QStringList = QList<QString>;
#else
class QStringList;
#endif
class QThread;
class QTimer;
class QUrl;
Expand Down
2 changes: 1 addition & 1 deletion Engine/FileSystemModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ FileSystemModel::data(const QModelIndex &index,
data = item->fileExtension();
break;
case DateModified:
data = item->getLastModified().toString(Qt::LocalDate);
data = item->getLastModified().toString(QLocale::system().dateTimeFormat());
break;
default:
break;
Expand Down
8 changes: 4 additions & 4 deletions Engine/OSGLContext_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

#include <dlfcn.h>

#include "Engine/AppManager.h"
#include "Engine/OSGLContext.h"
#include "Global/GLIncludes.h"

extern "C"
{
#include <X11/Xlib.h>
Expand All @@ -41,10 +45,6 @@ extern "C"
#include <X11/Xresource.h>
}

#include "Engine/AppManager.h"
#include "Engine/OSGLContext.h"
#include "Global/GLIncludes.h"

#define GLX_VENDOR 1
#define GLX_RGBA_BIT 0x00000001
#define GLX_WINDOW_BIT 0x00000001
Expand Down
4 changes: 4 additions & 0 deletions Engine/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,11 @@ Project::onAutoSaveTimerTriggered()
if (canAutoSave) {
std::shared_ptr<QFutureWatcher<void> > watcher = std::make_shared<QFutureWatcher<void> >();
QObject::connect( watcher.get(), SIGNAL(finished()), this, SLOT(onAutoSaveFutureFinished()) );
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
watcher->setFuture( QtConcurrent::run(&Project::autoSave, this) );
#else
watcher->setFuture( QtConcurrent::run(this, &Project::autoSave) );
#endif
_imp->autoSaveFutures.push_back(watcher);
} else {
///If the auto-save failed because a render is in progress, try every 2 seconds to auto-save.
Expand Down
4 changes: 4 additions & 0 deletions Engine/PyGlobalFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ class PyCoreApplication

inline int getBuildNumber() const
{
#ifdef NATRON_BUILD_NUMBER
return NATRON_BUILD_NUMBER;
#else
return 0;
#endif
}

inline bool is64Bit() const
Expand Down
2 changes: 1 addition & 1 deletion Engine/StandardPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ StandardPaths::writableLocation(StandardLocationEnum type)
path = QStandardPaths::HomeLocation;
break;
case StandardPaths::eStandardLocationData:
path = QStandardPaths::DataLocation;
path = QStandardPaths::AppDataLocation;
break;
case StandardPaths::eStandardLocationCache:
path = QStandardPaths::CacheLocation;
Expand Down
8 changes: 8 additions & 0 deletions Engine/TrackerNodeInteract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,11 @@ TrackerNodeInteract::refreshSelectedMarkerTexture()

imageGetterWatcher = std::make_shared<TrackWatcher>();
QObject::connect( imageGetterWatcher.get(), SIGNAL(finished()), this, SLOT(onTrackImageRenderingFinished()) );
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
imageGetterWatcher->setFuture( QtConcurrent::run(&TrackMarker::getMarkerImage, marker.get(), time, roi) );
#else
imageGetterWatcher->setFuture( QtConcurrent::run(marker.get(), &TrackMarker::getMarkerImage, time, roi) );
#endif
}

void
Expand Down Expand Up @@ -1130,7 +1134,11 @@ TrackerNodeInteract::makeMarkerKeyTexture(int time,
TrackWatcherPtr watcher( new TrackWatcher() );
QObject::connect( watcher.get(), SIGNAL(finished()), this, SLOT(onKeyFrameImageRenderingFinished()) );
trackRequestsMap[k] = watcher;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
watcher->setFuture( QtConcurrent::run(&TrackMarker::getMarkerImage, track.get(), time, k.roi) );
#else
watcher->setFuture( QtConcurrent::run(track.get(), &TrackMarker::getMarkerImage, time, k.roi) );
#endif
}
}

Expand Down
4 changes: 2 additions & 2 deletions Engine/typesystem_engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -791,9 +791,9 @@
<modify-function signature="renderInternal(bool,std::list&lt;Effect*&gt;,std::list&lt;int&gt;,std::list&lt;int&gt;,std::list&lt;int&gt;)" remove="all"/>
<modify-function signature="renderInternal(bool,Effect*,int,int,int)" remove="all"/>
<modify-function signature="render(std::list&lt;Effect*&gt;,std::list&lt;int&gt;,std::list&lt;int&gt;,std::list&lt;int&gt;)">
<modify-argument index="1">
<!--<modify-argument index="1"> This conversion fails to compile in PySide6, luckily Shiboken is smart enough to do it for ourselves
<replace-type modified-type="PyList"/>
</modify-argument>
</modify-argument>-->
<modify-argument index="2">
<remove-argument/>
</modify-argument>
Expand Down
12 changes: 5 additions & 7 deletions Gui/AboutWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ CLANG_DIAG_OFF(deprecated)
#include <QVBoxLayout>
#include <QTabWidget>
#include <QFile>
#include <QTextCodec>
#include <QItemSelectionModel>
#include <QHeaderView>
#include <QDir>
CLANG_DIAG_ON(deprecated)
#include <qhttpserver.h>

#include "Global/GlobalDefines.h"
#include "Global/GitVersion.h"
Expand Down Expand Up @@ -130,7 +128,7 @@ AboutWindow::AboutWindow(QWidget* parent)
QString licenseStr;
QFile license( QString::fromUtf8(":LICENSE_SHORT.txt") );
license.open(QIODevice::ReadOnly | QIODevice::Text);
licenseStr = NATRON_NAMESPACE::convertFromPlainText(QTextCodec::codecForName("UTF-8")->toUnicode( license.readAll() ), NATRON_NAMESPACE::WhiteSpaceNormal);
licenseStr = NATRON_NAMESPACE::convertFromPlainText(QString::fromUtf8( license.readAll() ), NATRON_NAMESPACE::WhiteSpaceNormal);
aboutText.append(licenseStr);
}
{
Expand Down Expand Up @@ -445,7 +443,7 @@ AboutWindow::AboutWindow(QWidget* parent)
{
QFile changelogFile( QString::fromUtf8(":CHANGELOG.md") );
changelogFile.open(QIODevice::ReadOnly | QIODevice::Text);
_changelogText->setText( QTextCodec::codecForName("UTF-8")->toUnicode( changelogFile.readAll() ) );
_changelogText->setText( QString::fromUtf8( changelogFile.readAll() ) );
}
_tabWidget->addTab( _changelogText, tr("Changelog") );

Expand All @@ -460,7 +458,7 @@ AboutWindow::AboutWindow(QWidget* parent)
{
QFile team_file( QString::fromUtf8(":CONTRIBUTORS.txt") );
team_file.open(QIODevice::ReadOnly | QIODevice::Text);
_teamText->setText( QTextCodec::codecForName("UTF-8")->toUnicode( team_file.readAll() ) );
_teamText->setText( QString::fromUtf8( team_file.readAll() ) );
}
_tabWidget->addTab( _teamText, tr("Contributors") );

Expand All @@ -469,7 +467,7 @@ AboutWindow::AboutWindow(QWidget* parent)
{
QFile license( QString::fromUtf8(":LICENSE.txt") );
license.open(QIODevice::ReadOnly | QIODevice::Text);
_licenseText->setText( QTextCodec::codecForName("UTF-8")->toUnicode( license.readAll() ) );
_licenseText->setText( QString::fromUtf8( license.readAll() ) );
}
_tabWidget->addTab( _licenseText, tr("License") );

Expand Down Expand Up @@ -563,7 +561,7 @@ AboutWindow::onSelectionChanged(const QItemSelection & newSelection,
fileName += ( item->text() == QString::fromUtf8("README") ) ? QString::fromUtf8(".md") : QString::fromUtf8(".txt");
QFile file(fileName);
if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
QString content = QTextCodec::codecForName("UTF-8")->toUnicode( file.readAll() );
QString content = QString::fromUtf8( file.readAll() );
_thirdPartyBrowser->setText(content);
}
}
Expand Down
4 changes: 4 additions & 0 deletions Gui/ClickableLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ KnobClickableLabel::~KnobClickableLabel()
}

void
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
KnobClickableLabel::enterEvent(QEnterEvent* e)
#else
KnobClickableLabel::enterEvent(QEvent* e)
#endif
{
_dnd->mouseEnter(e);
ClickableLabel::enterEvent(e);
Expand Down
4 changes: 4 additions & 0 deletions Gui/ClickableLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ class KnobClickableLabel

private:

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual void enterEvent(QEnterEvent* e) OVERRIDE FINAL;
#else
virtual void enterEvent(QEvent* e) OVERRIDE FINAL;
#endif
virtual void leaveEvent(QEvent* e) OVERRIDE FINAL;
virtual void keyPressEvent(QKeyEvent* e) OVERRIDE FINAL;
virtual void keyReleaseEvent(QKeyEvent* e) OVERRIDE FINAL;
Expand Down
4 changes: 4 additions & 0 deletions Gui/ColorSelectorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,12 @@ void ColorSelectorWidget::handleHexChanged()
value.prepend( QString::fromUtf8("#") );
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QColor color( QColor::fromString(_hex->text()) );
#else
QColor color;
color.setNamedColor( _hex->text() );
#endif
if ( !color.isValid() ) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions Gui/CurveEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,11 @@ CurveEditor::keyReleaseEvent(QKeyEvent* e)
}

void
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
CurveEditor::enterEvent(QEnterEvent* e)
#else
CurveEditor::enterEvent(QEvent* e)
#endif
{
enterEventBase();
QWidget::enterEvent(e);
Expand Down
4 changes: 4 additions & 0 deletions Gui/CurveEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ public Q_SLOTS:
private:

virtual QUndoStack* getUndoStack() const OVERRIDE FINAL WARN_UNUSED_RETURN;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual void enterEvent(QEnterEvent* e) OVERRIDE FINAL;
#else
virtual void enterEvent(QEvent* e) OVERRIDE FINAL;
#endif
virtual void leaveEvent(QEvent* e) OVERRIDE FINAL;
virtual void keyPressEvent(QKeyEvent* e) OVERRIDE FINAL;
virtual void keyReleaseEvent(QKeyEvent* e) OVERRIDE FINAL;
Expand Down
21 changes: 21 additions & 0 deletions Gui/CurveWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,11 @@ CurveWidget::mouseDoubleClickEvent(QMouseEvent* e)
QScreen* desktop = QGuiApplication::primaryScreen();
QRect screen = desktop->availableGeometry();

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QPoint gP = e->globalPosition().toPoint();
#else
QPoint gP = e->globalPos();
#endif
if ( gP.x() > (screen.width() - dialogW) ) {
gP.rx() -= dialogW;
}
Expand Down Expand Up @@ -1252,7 +1256,11 @@ CurveWidget::mouseMoveEvent(QMouseEvent* e)
}
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QPointF newClick_opengl = _imp->zoomCtx.toZoomCoordinates( e->position().x(), e->position().y() );
#else
QPointF newClick_opengl = _imp->zoomCtx.toZoomCoordinates( e->x(), e->y() );
#endif
QPointF oldClick_opengl = _imp->zoomCtx.toZoomCoordinates( _imp->_lastMousePos.x(), _imp->_lastMousePos.y() );
double dx = ( oldClick_opengl.x() - newClick_opengl.x() );
double dy = ( oldClick_opengl.y() - newClick_opengl.y() );
Expand Down Expand Up @@ -1294,7 +1302,11 @@ CurveWidget::mouseMoveEvent(QMouseEvent* e)
}
break;
case eEventStateSelecting:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
_imp->refreshSelectionRectangle( (double)e->position().x(), (double)e->position().y() );
#else
_imp->refreshSelectionRectangle( (double)e->x(), (double)e->y() );
#endif
break;

case eEventStateDraggingTangent:
Expand All @@ -1313,8 +1325,13 @@ CurveWidget::mouseMoveEvent(QMouseEvent* e)
if ( (_imp->zoomCtx.screenWidth() > 0) && (_imp->zoomCtx.screenHeight() > 0) ) {
_imp->zoomOrPannedSinceLastFit = true;

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
int deltaX = 2 * ( e->position().x() - _imp->_lastMousePos.x() );
int deltaY = -2 * ( e->position().y() - _imp->_lastMousePos.y() );
#else
int deltaX = 2 * ( e->x() - _imp->_lastMousePos.x() );
int deltaY = -2 * ( e->y() - _imp->_lastMousePos.y() );
#endif
// Wheel: zoom values and time, keep point under mouse
double scaleFactorX = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, deltaX);
double scaleFactorY = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, deltaY);
Expand Down Expand Up @@ -1592,7 +1609,11 @@ CurveWidget::keyPressEvent(QKeyEvent* e)
} // keyPressEvent

void
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
CurveWidget::enterEvent(QEnterEvent* e)
#else
CurveWidget::enterEvent(QEvent* e)
#endif
{
setFocus();
QOpenGLWidget::enterEvent(e);
Expand Down
4 changes: 4 additions & 0 deletions Gui/CurveWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ public Q_SLOTS:
virtual void mouseDoubleClickEvent(QMouseEvent* e) OVERRIDE FINAL;
virtual void mouseReleaseEvent(QMouseEvent* e) OVERRIDE FINAL;
virtual void mouseMoveEvent(QMouseEvent* e) OVERRIDE FINAL;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual void enterEvent(QEnterEvent* e) OVERRIDE FINAL;
#else
virtual void enterEvent(QEvent* e) OVERRIDE FINAL;
#endif
virtual void wheelEvent(QWheelEvent* e) OVERRIDE FINAL;
virtual void keyPressEvent(QKeyEvent* e) OVERRIDE FINAL;
virtual void focusInEvent(QFocusEvent* e) OVERRIDE FINAL;
Expand Down
Loading

0 comments on commit 876a222

Please sign in to comment.