Skip to content

Commit

Permalink
Fix compilation for Qt 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-w committed Jun 21, 2015
1 parent baf883d commit 4a3691f
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 24 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
25 changes: 25 additions & 0 deletions include/AtomicInt.h
Original file line number Diff line number Diff line change
@@ -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);

operator int() const;
};

#else

typedef QAtomicInt AtomicInt;

#endif // QT_VERSION >= 0x050000 && QT_VERSION <= 0x050300

#endif
5 changes: 3 additions & 2 deletions include/BufferManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#ifndef BUFFER_MANAGER_H
#define BUFFER_MANAGER_H

#include "AtomicInt.h"
#include "export.h"
#include "lmms_basics.h"

Expand All @@ -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;
};
Expand Down
5 changes: 3 additions & 2 deletions include/MixerWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef MIXER_WORKER_THREAD_H
#define MIXER_WORKER_THREAD_H

#include <AtomicInt.h>
#include <QtCore/QAtomicPointer>
#include <QtCore/QThread>

Expand Down Expand Up @@ -63,8 +64,8 @@ class MixerWorkerThread : public QThread
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;

} ;
Expand Down
3 changes: 2 additions & 1 deletion include/NotePlayHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
};

Expand Down
4 changes: 2 additions & 2 deletions include/ThreadableJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#ifndef THREADABLE_JOB_H
#define THREADABLE_JOB_H

#include <QtCore/QAtomicInt>
#include "AtomicInt.h"

#include "lmms_basics.h"

Expand Down Expand Up @@ -82,7 +82,7 @@ class ThreadableJob
protected:
virtual void doProcessing() = 0;

QAtomicInt m_state;
AtomicInt m_state;

} ;

Expand Down
2 changes: 1 addition & 1 deletion plugins/GigPlayer/GigPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" )
Expand Down
4 changes: 4 additions & 0 deletions plugins/lb302/lb302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
8 changes: 0 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
8 changes: 8 additions & 0 deletions src/core/AtomicInt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "AtomicInt.h"

AtomicInt::AtomicInt(int value) : QAtomicInt(value) {}

AtomicInt::operator int() const
{
return loadAcquire();
}
4 changes: 2 additions & 2 deletions src/core/BufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(LMMS_SRCS
${LMMS_SRCS}
core/AtomicInt.cpp
core/AutomatableModel.cpp
core/AutomationPattern.cpp
core/BandLimitedWave.cpp
Expand Down
6 changes: 3 additions & 3 deletions src/core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ConfigManager.h"
#include "MainWindow.h"
#include "ProjectVersion.h"
#include "GuiApplication.h"


static inline QString ensureTrailingSlash( const QString & _s )
Expand Down Expand Up @@ -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" ).
Expand Down Expand Up @@ -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 "
Expand Down
2 changes: 1 addition & 1 deletion src/core/NotePlayHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
2 changes: 1 addition & 1 deletion src/core/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QLibrary>
#include <QtGui/QMessageBox>
#include <QMessageBox>

#include "Plugin.h"
#include "embed.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "base64.h"

#include <QBuffer>
#include <QDataStream>
#include <QVariant>

namespace base64
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/FileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4a3691f

Please sign in to comment.