alerting race condition fix
[qtrapids] / src / server / TorrentSession.cpp
index 514b2c9..aa1f105 100644 (file)
@@ -48,6 +48,12 @@ namespace qtrapids
 
 
             if (ta) {
+
+                if (!ta->handle.is_valid()) {
+                    qDebug() << "handle is invalid";
+                    return;
+                }
+
                 TorrentHandle handle(ta->handle);
                 TorrentState state;
 
@@ -100,11 +106,12 @@ namespace qtrapids
 
         qDebug() << "addTorrent: " << path << " save to " << save_path;
         boost::intrusive_ptr<libtorrent::torrent_info> tiTmp
-            = new libtorrent::torrent_info(path.toStdString());
+            = new libtorrent::torrent_info
+            (boost::filesystem::path(path.toStdString()));
         addParams.ti = tiTmp;
 
         // save_path is the only mandatory parameter, rest are optional.
-        addParams.save_path = save_path.toStdString();
+        addParams.save_path = boost::filesystem::path(save_path.toStdString());
         //addParams.storage_mode = libtorrent::storage_mode_allocate;
 
         TorrentHandlePtr handle(new TorrentHandle(btSession_.add_torrent(addParams)));