Browse Source

Merge pull request #3685 from glassez/cpp11

Add C++11 support.
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
19ad58c394
  1. 11
      .travis.yml
  2. 4
      macxconf.pri
  3. 3
      os2conf.pri
  4. 5
      src/core/net/private/geoipdatabase.cpp
  5. 4
      src/core/preferences.cpp
  6. 31
      src/core/types.h
  7. 4
      src/gui/options_imp.cpp
  8. 4
      src/src.pro
  9. 4
      src/webui/prefjson.cpp
  10. 11
      unixconf.pri
  11. 3
      winconf-mingw.pri

11
.travis.yml

@ -43,14 +43,19 @@ addons:
branch_pattern: $coverity_branch branch_pattern: $coverity_branch
notification_email: sledgehammer999@qbittorrent.org notification_email: sledgehammer999@qbittorrent.org
apt: apt:
sources:
# sources list: https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
- ubuntu-toolchain-r-test
- boost-latest
packages: packages:
# packages list: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise # packages list: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
- autoconf - autoconf
- automake - automake
- colormake - colormake
- g++-4.8
- libssl-dev - libssl-dev
- libboost-dev - libboost1.55-dev
- libboost-system-dev - libboost-system1.55-dev
- libqt4-dev - libqt4-dev
# Uncomment when Travis upgraded "Ubuntu 12.04 LTS" to a newer version whose repo will have a more up-to-date libtorrent package # Uncomment when Travis upgraded "Ubuntu 12.04 LTS" to a newer version whose repo will have a more up-to-date libtorrent package
#- libtorrent-rasterbar6 #- libtorrent-rasterbar6
@ -60,6 +65,7 @@ before_install:
- if [ "$TRAVIS_BRANCH" = "$coverity_branch" ] && ! [ "$TRAVIS_OS_NAME" = "linux" -a "$lt_branch" = "RC_1_0" -a "$gui" = true ]; then exit ; fi - if [ "$TRAVIS_BRANCH" = "$coverity_branch" ] && ! [ "$TRAVIS_OS_NAME" = "linux" -a "$lt_branch" = "RC_1_0" -a "$gui" = true ]; then exit ; fi
- shopt -s expand_aliases - shopt -s expand_aliases
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CC=gcc-4.8 CXX=g++-4.8 ; fi
- if [ "$TRAVIS_BRANCH" != "$coverity_branch" -a "$TRAVIS_OS_NAME" = "linux" ]; then dpkg-query -L ccache && export PATH="/usr/lib/ccache/:$PATH" ; fi - if [ "$TRAVIS_BRANCH" != "$coverity_branch" -a "$TRAVIS_OS_NAME" = "linux" ]; then dpkg-query -L ccache && export PATH="/usr/lib/ccache/:$PATH" ; fi
- alias make="colormake -j3" # Using nprocs/2 sometimes may fail (gcc is killed by system) - alias make="colormake -j3" # Using nprocs/2 sometimes may fail (gcc is killed by system)
@ -90,6 +96,7 @@ install:
script: script:
- if [ "$TRAVIS_BRANCH" = "$coverity_branch" ]; then exit ; fi # Skip usual build when running coverity scan - if [ "$TRAVIS_BRANCH" = "$coverity_branch" ]; then exit ; fi # Skip usual build when running coverity scan
- ./bootstrap.sh && ./configure $qbtconf - ./bootstrap.sh && ./configure $qbtconf
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then echo QMAKE_CC=$CC >> conf.pri && echo QMAKE_CXX=$CXX >> conf.pri ; fi
- make && make install - make && make install
after_success: after_success:

4
macxconf.pri

@ -10,7 +10,9 @@ exists($$OUT_PWD/../conf.pri) {
} }
LIBS += -framework Carbon -framework IOKit LIBS += -framework Carbon -framework IOKit
CONFIG += c++11
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
QT_LANG_PATH = ../dist/qt-translations QT_LANG_PATH = ../dist/qt-translations
DIST_PATH = ../dist/mac DIST_PATH = ../dist/mac

3
os2conf.pri

@ -1,3 +1,6 @@
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
exists(conf.pri) { exists(conf.pri) {
# to the conf.pri goes all system dependent stuff # to the conf.pri goes all system dependent stuff
include(conf.pri) include(conf.pri)

5
src/core/net/private/geoipdatabase.cpp

@ -63,7 +63,7 @@ namespace
const quint32 __ENDIAN_TEST__ = 0x00000001; const quint32 __ENDIAN_TEST__ = 0x00000001;
const bool __IS_LITTLE_ENDIAN__ = (reinterpret_cast<const uchar *>(&__ENDIAN_TEST__)[0] == 0x01); const bool __IS_LITTLE_ENDIAN__ = (reinterpret_cast<const uchar *>(&__ENDIAN_TEST__)[0] == 0x01);
BEGIN_SCOPED_ENUM(DataType) enum class DataType
{ {
Unknown = 0, Unknown = 0,
Pointer = 1, Pointer = 1,
@ -81,8 +81,7 @@ namespace
EndMarker = 13, EndMarker = 13,
Boolean = 14, Boolean = 14,
Float = 15 Float = 15
} };
END_SCOPED_ENUM
struct DataFieldDescriptor struct DataFieldDescriptor
{ {

4
src/core/preferences.cpp

@ -974,12 +974,12 @@ void Preferences::setGlobalMaxRatio(qreal ratio)
MaxRatioAction Preferences::getMaxRatioAction() const MaxRatioAction Preferences::getMaxRatioAction() const
{ {
return value("Preferences/Bittorrent/MaxRatioAction", MaxRatioAction::Pause).toInt(); return value("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(MaxRatioAction::Pause)).value<MaxRatioAction>();
} }
void Preferences::setMaxRatioAction(MaxRatioAction act) void Preferences::setMaxRatioAction(MaxRatioAction act)
{ {
setValue("Preferences/Bittorrent/MaxRatioAction", act); setValue("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(act));
} }
// IP Filter // IP Filter

31
src/core/types.h

@ -31,43 +31,28 @@
#include <QVariant> #include <QVariant>
#define BEGIN_SCOPED_ENUM(name) class name\
{\
int m_val;\
\
public:\
name() {}\
name(int val) : m_val(val) {}\
operator int() const { return m_val; }\
operator QVariant() const { return m_val; }\
\
enum
#define END_SCOPED_ENUM ; };
const qlonglong MAX_ETA = 8640000; const qlonglong MAX_ETA = 8640000;
BEGIN_SCOPED_ENUM(MaxRatioAction) enum class MaxRatioAction
{ {
Pause, Pause,
Remove Remove
} };
END_SCOPED_ENUM
Q_DECLARE_METATYPE(MaxRatioAction)
BEGIN_SCOPED_ENUM(TorrentExportFolder) enum class TorrentExportFolder
{ {
Regular, Regular,
Finished Finished
} };
END_SCOPED_ENUM
BEGIN_SCOPED_ENUM(ShutdownAction) enum class ShutdownAction
{ {
None, None,
Shutdown, Shutdown,
Suspend, Suspend,
Hibernate Hibernate
} };
END_SCOPED_ENUM
#endif // TYPES_H #endif // TYPES_H

4
src/gui/options_imp.cpp

@ -469,7 +469,7 @@ void options_imp::saveOptions()
pref->setEncryptionSetting(getEncryptionSetting()); pref->setEncryptionSetting(getEncryptionSetting());
pref->enableAnonymousMode(checkAnonymousMode->isChecked()); pref->enableAnonymousMode(checkAnonymousMode->isChecked());
pref->setGlobalMaxRatio(getMaxRatio()); pref->setGlobalMaxRatio(getMaxRatio());
pref->setMaxRatioAction(comboRatioLimitAct->currentIndex()); pref->setMaxRatioAction(static_cast<MaxRatioAction>(comboRatioLimitAct->currentIndex()));
// End Bittorrent preferences // End Bittorrent preferences
// Misc preferences // Misc preferences
// * IPFilter // * IPFilter
@ -804,7 +804,7 @@ void options_imp::loadOptions()
spinMaxRatio->setEnabled(false); spinMaxRatio->setEnabled(false);
comboRatioLimitAct->setEnabled(false); comboRatioLimitAct->setEnabled(false);
} }
comboRatioLimitAct->setCurrentIndex(pref->getMaxRatioAction()); comboRatioLimitAct->setCurrentIndex(static_cast<int>(pref->getMaxRatioAction()));
// End Bittorrent preferences // End Bittorrent preferences
// Web UI preferences // Web UI preferences

4
src/src.pro

@ -2,6 +2,10 @@
TEMPLATE = app TEMPLATE = app
CONFIG += qt thread silent CONFIG += qt thread silent
# C++11 support
CONFIG += c++11
DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES
# Windows specific configuration # Windows specific configuration
win32: include(../winconf.pri) win32: include(../winconf.pri)

4
src/webui/prefjson.cpp

@ -141,7 +141,7 @@ QByteArray prefjson::getPreferences()
// Share Ratio Limiting // Share Ratio Limiting
data["max_ratio_enabled"] = (pref->getGlobalMaxRatio() >= 0.); data["max_ratio_enabled"] = (pref->getGlobalMaxRatio() >= 0.);
data["max_ratio"] = pref->getGlobalMaxRatio(); data["max_ratio"] = pref->getGlobalMaxRatio();
data["max_ratio_act"] = pref->getMaxRatioAction(); data["max_ratio_act"] = QVariant::fromValue(pref->getMaxRatioAction());
// Web UI // Web UI
// Language // Language
@ -337,7 +337,7 @@ void prefjson::setPreferences(const QString& json)
else else
pref->setGlobalMaxRatio(-1); pref->setGlobalMaxRatio(-1);
if (m.contains("max_ratio_act")) if (m.contains("max_ratio_act"))
pref->setMaxRatioAction(m["max_ratio_act"].toInt()); pref->setMaxRatioAction(m["max_ratio_act"].value<MaxRatioAction>());
// Web UI // Web UI
// Language // Language

11
unixconf.pri

@ -9,15 +9,14 @@ exists($$OUT_PWD/../conf.pri) {
include(conf.pri) include(conf.pri)
} }
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
# COMPILATION SPECIFIC # COMPILATION SPECIFIC
!nogui:dbus { !nogui:dbus: QT += dbus
QT += dbus
}
QMAKE_CXXFLAGS += -Wformat -Wformat-security QMAKE_CXXFLAGS += -Wformat -Wformat-security
!haiku { !haiku: QMAKE_LFLAGS_APP += -rdynamic
QMAKE_LFLAGS_APP += -rdynamic
}
# Man page # Man page
nogui { nogui {

3
winconf-mingw.pri

@ -1,3 +1,6 @@
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=gnu++11
strace_win{ strace_win{
contains(QMAKE_HOST.arch, x86) { contains(QMAKE_HOST.arch, x86) {
# i686 arch requires frame pointer preservation # i686 arch requires frame pointer preservation

Loading…
Cancel
Save