From c4aa23c86bb04fc2746a6c68f1a797c638a869da Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 23 Jul 2009 09:11:05 +0000 Subject: [PATCH] - Fixed torrent creation (closes #402025) --- src/createtorrent_imp.cpp | 17 +++++++++-------- src/createtorrent_imp.h | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index 396867822..000d08271 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -184,7 +184,6 @@ void createtorrent::on_createButton_clicked(){ void createtorrent::handleCreationFailure(QString msg) { QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg)); - hide(); } void createtorrent::handleCreationSuccess(QString path, const char* branch_path) { @@ -205,7 +204,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path) emit torrent_to_seed(path); } QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path); - hide(); + close(); } void createtorrent::updateProgressBar(int progress) { @@ -228,8 +227,12 @@ void torrentCreatorThread::create(QString _input_path, QString _save_path, QStri start(); } -void sendProgressUpdateSignal(int i, int num, QDialog *parent){ - ((createtorrent*)parent)->updateProgressBar((int)(i*100./(float)num)); +void sendProgressUpdateSignal(int i, int num, torrentCreatorThread *parent){ + parent->sendProgressSignal((int)(i*100./(float)num)); +} + +void torrentCreatorThread::sendProgressSignal(int progress) { + emit updateProgress(progress); } void torrentCreatorThread::run() { @@ -254,15 +257,13 @@ void torrentCreatorThread::run() { } if(abort) return; // calculate the hash for all pieces - set_piece_hashes(t, full_path.branch_path(), boost::bind(&sendProgressUpdateSignal, _1, t.num_pieces(), parent)); + set_piece_hashes(t, full_path.branch_path(), boost::bind(&sendProgressUpdateSignal, _1, t.num_pieces(), this)); // Set qBittorrent as creator and add user comment to // torrent_info structure t.set_creator(creator_str); t.set_comment((const char*)comment.toLocal8Bit()); // Is private ? - if(is_private){ - t.set_priv(true); - } + t.set_prive(is_private); if(abort) return; // create the torrent and print it to out ofstream out(complete(path((const char*)save_path.toLocal8Bit())), std::ios_base::binary); diff --git a/src/createtorrent_imp.h b/src/createtorrent_imp.h index ec09f9c45..a279e68cc 100644 --- a/src/createtorrent_imp.h +++ b/src/createtorrent_imp.h @@ -57,6 +57,7 @@ class torrentCreatorThread : public QThread { wait(); } void create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size); + void sendProgressSignal(int progress); protected: void run(); @@ -64,6 +65,8 @@ class torrentCreatorThread : public QThread { signals: void creationFailure(QString msg); void creationSuccess(QString path, const char* branch_path); + + signals: void updateProgress(int progress); };