Fix compilation for Qt 5.0

This commit is contained in:
Lukas W
2015-06-21 15:41:26 +02:00
parent baf883d808
commit 8b0b2df38e
15 changed files with 58 additions and 24 deletions

View File

@@ -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)

25
include/AtomicInt.h Normal file
View File

@@ -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 <QtCore/QAtomicInt>
#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

View File

@@ -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 @@ public:
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;
};

View File

@@ -25,6 +25,7 @@
#ifndef MIXER_WORKER_THREAD_H
#define MIXER_WORKER_THREAD_H
#include <AtomicInt.h>
#include <QtCore/QAtomicPointer>
#include <QtCore/QThread>
@@ -63,8 +64,8 @@ public:
private:
#define JOB_QUEUE_SIZE 1024
QAtomicPointer<ThreadableJob> m_items[JOB_QUEUE_SIZE];
QAtomicInt m_queueSize;
QAtomicInt m_itemsDone;
AtomicInt m_queueSize;
AtomicInt m_itemsDone;
OperationMode m_opMode;
} ;

View File

@@ -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 @@ public:
private:
static NotePlayHandle ** s_available;
static QReadWriteLock s_mutex;
static QAtomicInt s_availableIndex;
static AtomicInt s_availableIndex;
static int s_size;
};

View File

@@ -25,7 +25,7 @@
#ifndef THREADABLE_JOB_H
#define THREADABLE_JOB_H
#include <QtCore/QAtomicInt>
#include "AtomicInt.h"
#include "lmms_basics.h"
@@ -82,7 +82,7 @@ public:
protected:
virtual void doProcessing() = 0;
QAtomicInt m_state;
AtomicInt m_state;
} ;

View File

@@ -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 != "" )

View File

@@ -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 )
{

View File

@@ -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
#

View File

@@ -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;

View File

@@ -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 "

View File

@@ -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;

View File

@@ -25,7 +25,7 @@
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QLibrary>
#include <QtGui/QMessageBox>
#include <QMessageBox>
#include "Plugin.h"
#include "embed.h"

View File

@@ -28,6 +28,7 @@
#include "base64.h"
#include <QBuffer>
#include <QDataStream>
#include <QVariant>
namespace base64

View File

@@ -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