Fix compilation error on Windows

Fix possible encoding problem on Windows (torrent creation tool)
Fix compilation with boost >= v1.46
This commit is contained in:
Christophe Dumez 2011-02-26 15:04:15 +00:00
parent 2da5e03741
commit c05e6ba580
5 changed files with 12 additions and 20 deletions

View file

@ -80,6 +80,7 @@
using namespace libtorrent;
QBtSession* QBtSession::m_instance = 0;
const qreal QBtSession::MAX_RATIO = 9999.;
const int MAX_TRACKER_ERRORS = 2;
enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL };

View file

@ -66,7 +66,7 @@ class QBtSession : public QObject {
Q_DISABLE_COPY(QBtSession)
public:
static const qreal MAX_RATIO = 9999.;
static const qreal MAX_RATIO;
private:
explicit QBtSession();

View file

@ -52,6 +52,10 @@ DEFINES += QT_NO_CAST_TO_ASCII
# Fast concatenation (Qt >= 4.6)
DEFINES += QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS
# Fixes compilation with Boost >= v1.46 where boost
# filesystem v3 is the default.
DEFINES += BOOST_FILESYSTEM_VERSION=2
INCLUDEPATH += $$PWD

View file

@ -85,16 +85,11 @@ void TorrentCreatorThread::sendProgressSignal(int progress) {
void TorrentCreatorThread::run() {
emit updateProgress(0);
char const* creator_str = "qBittorrent "VERSION;
QString creator_str("qBittorrent "VERSION);
try {
file_storage fs;
#if LIBTORRENT_VERSION_MINOR >= 16
add_files(fs, input_path.toUtf8().constData(), file_filter);
#else
// Adding files to the torrent
path full_path = path(input_path.toUtf8().constData());
add_files(fs, full_path, file_filter);
#endif
add_files(fs, input_path.toUtf8().constData(), file_filter);
if(abort) return;
create_torrent t(fs, piece_size);
@ -107,20 +102,12 @@ void TorrentCreatorThread::run() {
}
if(abort) return;
// calculate the hash for all pieces
#if LIBTORRENT_VERSION_MINOR >= 16
QString parent_path = input_path.replace("\\", "/");
QStringList parts = parent_path.split("/"/*, QString::SkipEmptyParts*/);
parts.removeLast();
parent_path = parts.join("/");
const QString parent_path = misc::branchPath(input_path);
set_piece_hashes(t, parent_path.toUtf8().constData(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), this));
#else
QString parent_path = misc::toQStringU(full_path.branch_path().string());
set_piece_hashes(t, full_path.branch_path(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), this));
#endif
// Set qBittorrent as creator and add user comment to
// torrent_info structure
t.set_creator(creator_str);
t.set_comment((const char*)comment.toUtf8());
t.set_creator(creator_str.toUtf8().constData());
t.set_comment(comment.toUtf8().constData());
// Is private ?
t.set_priv(is_private);
if(abort) return;

View file

@ -1,5 +1,5 @@
# Adapt these paths on Windows
INCLUDEPATH += $$quote(C:/qBittorrent/boost_1_44_0)
INCLUDEPATH += $$quote(C:/qBittorrent/boost_1_46_0)
INCLUDEPATH += $$quote(C:/qBittorrent/RC_0_15/include)
INCLUDEPATH += $$quote(C:/qBittorrent/RC_0_15/zlib)
INCLUDEPATH += $$quote(C:/OpenSSL/include)