From baf883d80859538df4714b55e33a1898a5e6085c Mon Sep 17 00:00:00 2001 From: Lukas W Date: Tue, 16 Jun 2015 18:23:01 +0200 Subject: [PATCH 1/2] Travis: Add Qt5 job --- .travis.yml | 1 + .travis/linux..before_install.sh | 4 ++++ .travis/linux..install.sh | 17 +++++++++++++---- .travis/linux..script.sh | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33759127386..a9530841608 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ matrix: include: - env: TARGET_OS=win32 - env: TARGET_OS=win64 + - env: QT5=True - os: osx before_install: - sh ${TRAVIS_BUILD_DIR}/.travis/${TRAVIS_OS_NAME}.${TARGET_OS}.before_install.sh diff --git a/.travis/linux..before_install.sh b/.travis/linux..before_install.sh index 233bd784f77..90da2764013 100644 --- a/.travis/linux..before_install.sh +++ b/.travis/linux..before_install.sh @@ -1,2 +1,6 @@ sudo add-apt-repository ppa:kalakris/cmake -y; +if [ $QT5 ] + then + sudo add-apt-repository ppa:ubuntu-sdk-team/ppa -y +fi sudo apt-get update -qq diff --git a/.travis/linux..install.sh b/.travis/linux..install.sh index 49a6ea466ac..8bbaf24ad40 100644 --- a/.travis/linux..install.sh +++ b/.travis/linux..install.sh @@ -1,4 +1,13 @@ -sudo apt-get install -y cmake libqt4-dev libsndfile-dev fftw3-dev libvorbis-dev \ - libogg-dev libasound2-dev libjack-dev libsdl-dev libsamplerate0-dev \ - libstk0-dev libfluidsynth-dev portaudio19-dev wine-dev g++-multilib \ - libfltk1.3-dev libgig-dev +PACKAGES="cmake libsndfile-dev fftw3-dev libvorbis-dev libogg-dev + libasound2-dev libjack-dev libsdl-dev libsamplerate0-dev libstk0-dev + libfluidsynth-dev portaudio19-dev wine-dev g++-multilib libfltk1.3-dev + libgig-dev" + +if [ $QT5 ] +then + PACKAGES="$PACKAGES qtbase5-dev" +else + PACKAGES="$PACKAGES libqt4-dev" +fi + +sudo apt-get install -y $PACKAGES diff --git a/.travis/linux..script.sh b/.travis/linux..script.sh index c9de77d364d..3403b74f289 100644 --- a/.travis/linux..script.sh +++ b/.travis/linux..script.sh @@ -1 +1 @@ -cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_WERROR=ON .. +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_WERROR=ON -DWANT_QT5=$QT5 .. From 8b0b2df38e7ed2a03780ceed3bd8c870acd62e83 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 21 Jun 2015 15:41:26 +0200 Subject: [PATCH 2/2] Fix compilation for Qt 5.0 --- CMakeLists.txt | 9 +++++++++ include/AtomicInt.h | 25 +++++++++++++++++++++++++ include/BufferManager.h | 5 +++-- include/MixerWorkerThread.h | 5 +++-- include/NotePlayHandle.h | 3 ++- include/ThreadableJob.h | 4 ++-- plugins/GigPlayer/GigPlayer.cpp | 2 +- plugins/lb302/lb302.cpp | 4 ++++ src/CMakeLists.txt | 8 -------- src/core/BufferManager.cpp | 4 ++-- src/core/ConfigManager.cpp | 6 +++--- src/core/NotePlayHandle.cpp | 2 +- src/core/Plugin.cpp | 2 +- src/core/base64.cpp | 1 + src/gui/dialogs/FileDialog.cpp | 2 +- 15 files changed, 58 insertions(+), 24 deletions(-) create mode 100644 include/AtomicInt.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ae89c1a15be..05d39a00832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,15 @@ IF(WANT_QT5) ${Qt5Xml_INCLUDE_DIRS} ) + SET(QT_LIBRARIES + Qt5::Core + Qt5::Gui + Qt5::Widgets + Qt5::Xml + ) + + FIND_PACKAGE(Qt5Test) + SET(QT_QTTEST_LIBRARY Qt5::Test) ELSE() SET(QT5 FALSE) diff --git a/include/AtomicInt.h b/include/AtomicInt.h new file mode 100644 index 00000000000..46da8ab5f3d --- /dev/null +++ b/include/AtomicInt.h @@ -0,0 +1,25 @@ +/// \file AtomicInt.h +/// \brief Compatibility subclass of QAtomicInt for supporting both Qt4 and Qt5 + +#ifndef LMMS_ATOMIC_H +#define LMMS_ATOMIC_H + +#include + +#if QT_VERSION >= 0x050000 && QT_VERSION <= 0x050300 + +class AtomicInt : public QAtomicInt +{ +public: + AtomicInt(int value=0) : QAtomicInt(value) {}; + + operator int() const {return loadAcquire();} +}; + +#else + +typedef QAtomicInt AtomicInt; + +#endif // QT_VERSION >= 0x050000 && QT_VERSION <= 0x050300 + +#endif diff --git a/include/BufferManager.h b/include/BufferManager.h index b40b431431e..eb80209ec2b 100644 --- a/include/BufferManager.h +++ b/include/BufferManager.h @@ -26,6 +26,7 @@ #ifndef BUFFER_MANAGER_H #define BUFFER_MANAGER_H +#include "AtomicInt.h" #include "export.h" #include "lmms_basics.h" @@ -45,10 +46,10 @@ class EXPORT BufferManager private: static sampleFrame ** s_available; - static QAtomicInt s_availableIndex; + static AtomicInt s_availableIndex; static sampleFrame ** s_released; - static QAtomicInt s_releasedIndex; + static AtomicInt s_releasedIndex; // static QReadWriteLock s_mutex; static int s_size; }; diff --git a/include/MixerWorkerThread.h b/include/MixerWorkerThread.h index e95c13a3b91..92577a80add 100644 --- a/include/MixerWorkerThread.h +++ b/include/MixerWorkerThread.h @@ -25,6 +25,7 @@ #ifndef MIXER_WORKER_THREAD_H #define MIXER_WORKER_THREAD_H +#include #include #include @@ -63,8 +64,8 @@ class MixerWorkerThread : public QThread private: #define JOB_QUEUE_SIZE 1024 QAtomicPointer m_items[JOB_QUEUE_SIZE]; - QAtomicInt m_queueSize; - QAtomicInt m_itemsDone; + AtomicInt m_queueSize; + AtomicInt m_itemsDone; OperationMode m_opMode; } ; diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 9cabdc346c8..bedc095f54d 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -26,6 +26,7 @@ #ifndef NOTE_PLAY_HANDLE_H #define NOTE_PLAY_HANDLE_H +#include "AtomicInt.h" #include "Note.h" #include "PlayHandle.h" #include "Track.h" @@ -335,7 +336,7 @@ class NotePlayHandleManager private: static NotePlayHandle ** s_available; static QReadWriteLock s_mutex; - static QAtomicInt s_availableIndex; + static AtomicInt s_availableIndex; static int s_size; }; diff --git a/include/ThreadableJob.h b/include/ThreadableJob.h index f116a9324b3..826c01654fa 100644 --- a/include/ThreadableJob.h +++ b/include/ThreadableJob.h @@ -25,7 +25,7 @@ #ifndef THREADABLE_JOB_H #define THREADABLE_JOB_H -#include +#include "AtomicInt.h" #include "lmms_basics.h" @@ -82,7 +82,7 @@ class ThreadableJob protected: virtual void doProcessing() = 0; - QAtomicInt m_state; + AtomicInt m_state; } ; diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index 22d539a6392..1f81f151e28 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -1060,7 +1060,7 @@ void GigInstrumentView::showFileDialog() QStringList types; types << tr( "GIG Files (*.gig)" ); - ofd.setFilters( types ); + ofd.setNameFilters( types ); QString dir; if( k->m_filename != "" ) diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index 5864b94c8d9..85320d21d01 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.cpp @@ -469,7 +469,11 @@ int lb302Synth::process(sampleFrame *outbuf, const int size) float samp; // Hold on to the current VCF, and use it throughout this period +#if QT_VERSION >= 0x050000 + lb302Filter *filter = vcf.loadAcquire(); +#else lb302Filter *filter = vcf; +#endif if( release_frame == 0 || ! m_playingNote ) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 603bc2a9ac7..318e3371e59 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,14 +115,6 @@ TARGET_LINK_LIBRARIES(lmms ${LMMS_REQUIRED_LIBS} ) -IF(QT5) - TARGET_LINK_LIBRARIES(lmms - Qt5::Widgets - Qt5::Xml -) -ENDIF() - - # # rules for building localizations # diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index 1f535443e70..afea2f27723 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -31,9 +31,9 @@ #include "MemoryManager.h" sampleFrame ** BufferManager::s_available; -QAtomicInt BufferManager::s_availableIndex = 0; +AtomicInt BufferManager::s_availableIndex = 0; sampleFrame ** BufferManager::s_released; -QAtomicInt BufferManager::s_releasedIndex = 0; +AtomicInt BufferManager::s_releasedIndex = 0; //QReadWriteLock BufferManager::s_mutex; int BufferManager::s_size; diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 6d07ab22292..4aa8f0675ec 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -31,6 +31,7 @@ #include "ConfigManager.h" #include "MainWindow.h" #include "ProjectVersion.h" +#include "GuiApplication.h" static inline QString ensureTrailingSlash( const QString & _s ) @@ -340,7 +341,7 @@ void ConfigManager::loadConfigFile() #endif setBackgroundArtwork( value( "paths", "backgroundartwork" ) ); } - else if( QApplication::type() == QApplication::GuiClient ) + else if( gui ) { QMessageBox::warning( NULL, MainWindow::tr( "Configuration file" ), MainWindow::tr( "Error while parsing configuration file at line %1:%2: %3" ). @@ -401,8 +402,7 @@ void ConfigManager::loadConfigFile() searchPaths << artworkDir() << defaultArtworkDir(); QDir::setSearchPaths( "resources", searchPaths); - if( !QDir( m_workingDir ).exists() && - QApplication::type() == QApplication::GuiClient && + if( !QDir( m_workingDir ).exists() && gui && QMessageBox::question( 0, MainWindow::tr( "Working directory" ), MainWindow::tr( "The LMMS working directory %1 does not " diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index be5a3829593..368cecb9a58 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -559,7 +559,7 @@ void NotePlayHandle::resize( const bpm_t _new_tempo ) NotePlayHandle ** NotePlayHandleManager::s_available; QReadWriteLock NotePlayHandleManager::s_mutex; -QAtomicInt NotePlayHandleManager::s_availableIndex; +AtomicInt NotePlayHandleManager::s_availableIndex; int NotePlayHandleManager::s_size; diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 9d79bac6229..2bdb66620bf 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include "Plugin.h" #include "embed.h" diff --git a/src/core/base64.cpp b/src/core/base64.cpp index 0479d468bf0..bc09982b6bd 100644 --- a/src/core/base64.cpp +++ b/src/core/base64.cpp @@ -28,6 +28,7 @@ #include "base64.h" #include +#include #include namespace base64 diff --git a/src/gui/dialogs/FileDialog.cpp b/src/gui/dialogs/FileDialog.cpp index ec991161066..93546c497f1 100644 --- a/src/gui/dialogs/FileDialog.cpp +++ b/src/gui/dialogs/FileDialog.cpp @@ -35,7 +35,7 @@ FileDialog::FileDialog( QWidget *parent, const QString &caption, const QString &directory, const QString &filter ) : QFileDialog( parent, caption, directory, filter ) { -#if QT_VERSION >= 0x040806 +#if (QT_VERSION >= 0x040806 && QT_VERSION < 0x050000) || QT_VERSION > 0x050200 setOption( QFileDialog::DontUseCustomDirectoryIcons ); #endif