Browse Source

Merge pull request #10833 from Chocobo1/invokeMethod

Use functor based QMetaObject::invokeMethod
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
1831f71cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      cmake/Modules/FindLibtorrentRasterbar.cmake
  2. 7
      conf.pri.windows
  3. 5
      src/base/asyncfilestorage.cpp
  4. 30
      src/base/bittorrent/session.cpp
  5. 5
      src/base/rss/private/rss_parser.cpp
  6. 1
      winconf.pri

1
cmake/Modules/FindLibtorrentRasterbar.cmake

@ -39,7 +39,6 @@ else()
# hope that they apply. If not, you the user are on your own. # hope that they apply. If not, you the user are on your own.
set(LibtorrentRasterbar_DEFINITIONS set(LibtorrentRasterbar_DEFINITIONS
-DTORRENT_USE_OPENSSL -DTORRENT_USE_OPENSSL
-DTORRENT_DISABLE_GEO_IP
-DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_ENABLE_CANCELIO
-DUNICODE -D_UNICODE -D_FILE_OFFSET_BITS=64) -DUNICODE -D_UNICODE -D_FILE_OFFSET_BITS=64)
endif() endif()

7
conf.pri.windows

@ -46,15 +46,10 @@ DEFINES += BOOST_SYSTEM_STATIC_LINK
#DEFINES += BOOST_SYSTEM_DYN_LINK #DEFINES += BOOST_SYSTEM_DYN_LINK
# Boost 1.60+ defaults to Vista+ support. The define below enables XP support again. # Boost 1.60+ defaults to Vista+ support. The define below enables XP support again.
DEFINES += BOOST_USE_WINAPI_VERSION=0x0501 DEFINES += BOOST_USE_WINAPI_VERSION=0x0501
# Enable if building against libtorrent 1.0.x (RC_1_0) (static linking)
#DEFINES += BOOST_ASIO_SEPARATE_COMPILATION
# Enable if building against libtorrent 1.0.x (RC_1_0) (dynamic linking)
#DEFINES += BOOST_ASIO_DYN_LINK
# Enable if encountered build error with boost version <= 1.59 # Enable if encountered build error with boost version <= 1.59
#DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES #DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES
# Enable if building against libtorrent 1.1.x (RC_1_1) # Enable if libtorrent was built with this flag defined
# built with this flag defined
#DEFINES += TORRENT_NO_DEPRECATE #DEFINES += TORRENT_NO_DEPRECATE
# Enable if linking dynamically against libtorrent # Enable if linking dynamically against libtorrent
#DEFINES += TORRENT_LINKING_SHARED #DEFINES += TORRENT_LINKING_SHARED

5
src/base/asyncfilestorage.cpp

@ -54,8 +54,13 @@ AsyncFileStorage::~AsyncFileStorage()
void AsyncFileStorage::store(const QString &fileName, const QByteArray &data) void AsyncFileStorage::store(const QString &fileName, const QByteArray &data)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this, [this, data, fileName]() { store_impl(fileName, data); }
, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "store_impl", Qt::QueuedConnection QMetaObject::invokeMethod(this, "store_impl", Qt::QueuedConnection
, Q_ARG(QString, fileName), Q_ARG(QByteArray, data)); , Q_ARG(QString, fileName), Q_ARG(QByteArray, data));
#endif
} }
QDir AsyncFileStorage::storageDir() const QDir AsyncFileStorage::storageDir() const

30
src/base/bittorrent/session.cpp

@ -422,7 +422,11 @@ Session::Session(QObject *parent)
m_nativeSession = new lt::session {pack, LTSessionFlags {0}}; m_nativeSession = new lt::session {pack, LTSessionFlags {0}};
m_nativeSession->set_alert_notify([this]() m_nativeSession->set_alert_notify([this]()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this, &Session::readAlerts, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "readAlerts", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "readAlerts", Qt::QueuedConnection);
#endif
}); });
configurePeerClasses(); configurePeerClasses();
@ -1534,13 +1538,12 @@ void Session::processShareLimits()
if (torrent->seedingTimeLimit() != TorrentHandle::NO_SEEDING_TIME_LIMIT) { if (torrent->seedingTimeLimit() != TorrentHandle::NO_SEEDING_TIME_LIMIT) {
const qlonglong seedingTimeInMinutes = torrent->seedingTime() / 60; const qlonglong seedingTimeInMinutes = torrent->seedingTime() / 60;
int seedingTimeLimit = torrent->seedingTimeLimit(); int seedingTimeLimit = torrent->seedingTimeLimit();
if (seedingTimeLimit == TorrentHandle::USE_GLOBAL_SEEDING_TIME) if (seedingTimeLimit == TorrentHandle::USE_GLOBAL_SEEDING_TIME) {
// If Global Seeding Time Limit is really set... // If Global Seeding Time Limit is really set...
seedingTimeLimit = globalMaxSeedingMinutes(); seedingTimeLimit = globalMaxSeedingMinutes();
}
if (seedingTimeLimit >= 0) { if (seedingTimeLimit >= 0) {
qDebug("Seeding Time: %d (limit: %d)", seedingTimeInMinutes, seedingTimeLimit);
if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) { if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) {
Logger *const logger = Logger::instance(); Logger *const logger = Logger::instance();
if (m_maxRatioAction == Remove) { if (m_maxRatioAction == Remove) {
@ -2190,14 +2193,24 @@ void Session::saveTorrentsQueue()
data += (hash.toLatin1() + '\n'); data += (hash.toLatin1() + '\n');
const QString filename = QLatin1String {"queue"}; const QString filename = QLatin1String {"queue"};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, data, filename]() { m_resumeDataSavingManager->save(filename, data); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "save" QMetaObject::invokeMethod(m_resumeDataSavingManager, "save"
, Q_ARG(QString, filename), Q_ARG(QByteArray, data)); , Q_ARG(QString, filename), Q_ARG(QByteArray, data));
#endif
} }
void Session::removeTorrentsQueue() void Session::removeTorrentsQueue()
{ {
const QString filename = QLatin1String {"queue"}; const QString filename = QLatin1String {"queue"};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, filename]() { m_resumeDataSavingManager->remove(filename); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, filename)); QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, filename));
#endif
} }
void Session::setDefaultSavePath(QString path) void Session::setDefaultSavePath(QString path)
@ -3471,8 +3484,13 @@ void Session::handleTorrentResumeDataReady(TorrentHandle *const torrent, const l
lt::bencode(std::back_inserter(out), data); lt::bencode(std::back_inserter(out), data);
const QString filename = QString("%1.fastresume").arg(torrent->hash()); const QString filename = QString("%1.fastresume").arg(torrent->hash());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, filename, out]() { m_resumeDataSavingManager->save(filename, out); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "save", QMetaObject::invokeMethod(m_resumeDataSavingManager, "save",
Q_ARG(QString, filename), Q_ARG(QByteArray, out)); Q_ARG(QString, filename), Q_ARG(QByteArray, out));
#endif
} }
void Session::handleTorrentResumeDataFailed(TorrentHandle *const torrent) void Session::handleTorrentResumeDataFailed(TorrentHandle *const torrent)
@ -3530,7 +3548,13 @@ void Session::initResumeFolder()
void Session::configureDeferred() void Session::configureDeferred()
{ {
if (!m_deferredConfigureScheduled) { if (!m_deferredConfigureScheduled) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this
, static_cast<void (Session::*)()>(&Session::configure)
, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "configure", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "configure", Qt::QueuedConnection);
#endif
m_deferredConfigureScheduled = true; m_deferredConfigureScheduled = true;
} }
} }

5
src/base/rss/private/rss_parser.cpp

@ -535,8 +535,13 @@ Parser::Parser(const QString lastBuildDate)
void Parser::parse(const QByteArray &feedData) void Parser::parse(const QByteArray &feedData)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this, [this, feedData]() { parse_impl(feedData); }
, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "parse_impl", Qt::QueuedConnection QMetaObject::invokeMethod(this, "parse_impl", Qt::QueuedConnection
, Q_ARG(QByteArray, feedData)); , Q_ARG(QByteArray, feedData));
#endif
} }
// read and create items from a rss document // read and create items from a rss document

1
winconf.pri

@ -5,7 +5,6 @@ DEFINES += BOOST_ASIO_DISABLE_CONNECTEX
DEFINES += BOOST_EXCEPTION_DISABLE DEFINES += BOOST_EXCEPTION_DISABLE
DEFINES += TORRENT_USE_OPENSSL DEFINES += TORRENT_USE_OPENSSL
DEFINES += TORRENT_DISABLE_GEO_IP
DEFINES += TORRENT_DISABLE_RESOLVE_COUNTRIES DEFINES += TORRENT_DISABLE_RESOLVE_COUNTRIES
DEFINES += UNICODE DEFINES += UNICODE

Loading…
Cancel
Save