Commit graph

374 commits

Author SHA1 Message Date
Ivan Sorokin
333978f1ff Use std::vector instead of std::deque in QAlertDispatcher
As we never use {push,pop}_front std::vector works here perfectly.
Also reserve memory for std::vector out of lock.

This could be considered as an optimization, but in reality this is just
using right container in right place. According to my measurements total
speedup is under 0.2%.
2014-10-12 12:25:47 +04:00
Ivan Sorokin
d89d9c2f75 Fewer calls to torrent_handle::info_hash() 2014-10-12 12:09:52 +04:00
sledgehammer999
97419f840a Consider queued items before deciding to 'auto-shutdown on downloads completion'. Closes #1942. 2014-09-21 13:50:32 +03:00
Nick Tiskov
a7e445c575 Work around magnet redirection in feeds 2014-09-16 00:35:46 +04:00
lojack5
ac3efb664a fix import torrent with "Keep incomplete torrents in:" ticked
* also had to account for "Append the label of the torrent to the save path",
  but again, this was only an issue when "Keep incomplete torrents in:" is
  selected

* A multi-file torrent with only one file (ie: a single file within a folder),
  was being treated as a single-file torrent, making it impossible to import.
  Multi-file torrent detection code was copied from libtorrent.  The
  information is available in libtorrent (under torrent_info::m_multifile),
  however it's a private member and I chose to go with copying the code that
  determines it, rather than modifying a library qBittorrent depends on.

Conflicts:
	src/torrentimportdlg.cpp
2014-09-15 00:05:13 +03:00
sledgehammer999
bf0ed595c7 Don't use IPv4 addresses when the user has enabled IPv6 address in the settings. 2014-09-02 14:45:42 +03:00
sledgehammer999
0b8fad69fa Option to disable connections not supported by proxies. Closes #1894. 2014-08-26 00:32:10 +03:00
sledgehammer999
58ad90fa9c Set 'Cancel' as the default button in the shutdown confirmation dialog. 2014-08-23 23:22:47 +03:00
sledgehammer999
f6156217d0 Added 'Shutdown now' button in shutdown confirmation dialog. Closes #969. 2014-08-23 22:22:03 +03:00
sledgehammer999
634000e7a9 Split ShutdownConfirmDlg into .h/.cpp files. 2014-08-23 21:55:38 +03:00
sledgehammer999
66b375de07 Don't listen on IPv6 address by default. Prevents network connectivity problems. Closes #1880. 2014-08-23 21:55:36 +03:00
sledgehammer999
efb3936ef1 Fix the adding of .torrent files via http links which was broken by 30bc5a1da6. 2014-08-15 11:33:09 +03:00
sledgehammer999
e294b2f456 Added 'Ratio Limit' column. Closes #936. 2014-08-14 21:05:53 +03:00
sledgehammer999
e0190d5576 Add 'Completed' column. Closes #1241. 2014-08-14 20:22:02 +03:00
sledgehammer999
36cba3b354 When qBT is launched with a magnet don't show it in the transferlist while the metadata are being loaded in the background. 2014-08-09 22:07:49 +03:00
sledgehammer999
80d6a5a73e Allow disabling of OS cache. This will prevent RAM increases on Windows when seeding many files. Closes #1699. 2014-08-07 23:09:58 +03:00
sledgehammer999
d8d95d2195 Migrate everything to use the new Preferences class and not access directly the qbittorrent.ini file. 2014-08-05 02:34:21 +03:00
sledgehammer999
8f32f86453 Merge pull request #1782 from sorokin/alert-disp-qt5
Fix alertdispatcher.cpp compilability on Qt5.
2014-07-20 20:21:29 +03:00
sledgehammer999
e2748ec3ac Remove deprecated feature of separate DHT port. 2014-07-16 00:17:21 +03:00
sledgehammer999
d6d20074be Merge pull request #1447 from BrunoReX/hibernation
Add option to hibernate computer in Auto-Shutdown menu
2014-07-06 23:11:29 +03:00
sledgehammer999
9a18b50751 Some fixes for commit 6dabf50781. 2014-07-06 21:39:27 +03:00
Bruno Barbieri
00e09435b2 Add option to hibernate computer in Auto-Shutdown menu 2014-07-06 06:13:36 -03:00
Ivan Sorokin
6dabf50781 Speedup and fix a bug in torrent moving.
This commit implements a map where qbittorrent store a state of
current torrent movings. This commit speed up
torrents moving a bit and also fix a bug when qbittorrent doesn't do
cleanup action when a single torrent is moved several times without
waiting for a previous move to complete.

How it worked before.

Libtorrent has a function torrent_handle::move_storage() that allows to move a
torrent to a specific directory. This function is asynchorous. It means that
this function quits instantaneously and when the actual operation
completes the alert 'storage_moved_alert' or
'storage_moved_failed_alert' will be sent. The storage_moved_alert contains a
torrent_handle and a new path to where the torrent is moved.

During handling of storage_moved_alert, qbittorrent needs not only new path,
but also an old path to perform some of cleanup actions (like removing an old
folder if it is empty). This was achieved by storing a value named
'previous save path' in TorrentPersistentData. A previous save path is
written when move_storage() is issued and is read when
storage_moved_alert is received.

Problems.

This mechanism has two negative aspects:

1. TorrentPersistentData is very slow. As torrent_handle::move_storage() is asynchoronous,
TorrentPersistentData is responsible for more that 99.8% of time
QTorrentHandle::move_storage(). This percent could be higher when there
are lots of torrents and lower when there are few of them.

2. TorrentPersistentData stores only one previous path. But many
move_storage()'s could be issued without waiting for previous to
complete. Subsequent move_storage()'s overwrites previous save path of a
previous move.

A fix.

The fix is simple. Before issueing move_storage() the oldPath is stored in
a special map called 'torrentMoveStates'. When a storage_moved_alert
is received the map is consulted and an alert is handled.

When user moves torrent when previous moving have not yet finished, the
new location is saved in a field 'queuedPath' the same map. When
torrent moving is completed (or failed) qbittorrent attemps to perform
move again to the queued location.

Future direction.

This fix removes one slow read and one slow write to
TorrentPersistentData on torrent moving, but there is still exists
TorrentPersistentData::saveSavePath in handleStorageMovedAlert(), so
overall time for UI hang should be reduced only threefold. A speeding up
TorrentPersistentData should be addressed in a separate commit.

I don't know if I should clean up torrentMoveStates when torrent is
deleted. In any case, torrent could be deleted when corresponding alert
is in alert queue. So if we decide to clean up torrentMoveStates, then
we should not treat receiving alert from unknown torrent as a error.
2014-06-23 11:21:24 +04:00
Ivan Sorokin
ce9da1ba1e Fix alertdispatcher.cpp compilability on Qt5. 2014-06-23 00:14:58 +04:00
sledgehammer999
d58d87a691 Use completed time from libtorrent directly. Closes #1726. 2014-06-07 14:44:08 +03:00
sledgehammer999
07f76f4939 Merge pull request #1733 from glassez/fix_build
Fix building with Qt5 (missing QObject decl).
2014-06-04 21:55:52 +03:00
sledgehammer999
a361c0ea03 Use the torrent_status for the queue_position too. 2014-06-04 20:26:23 +03:00
Vladimir Golovnev (Glassez)
446a9efe9e Fix building with Qt5 (missing QObject decl). 2014-06-04 17:38:35 +04:00
Ivan Sorokin
510818d631 Replaced dynamic_cast with switch on alert type.
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-04 11:08:31 +04:00
Ivan Sorokin
1244a46cbb Extract alert handling to separate functions. 2014-06-04 11:08:31 +04:00
sledgehammer999
27c641ffaa Rework the GUI code for private torrents. 2014-06-04 00:49:03 +03:00
Ivan Sorokin
32c203d2e6 Copyright notices for alert dispatcher. 2014-06-04 01:40:00 +04:00
sledgehammer999
a6fa27467f Fix previous commits. 2014-06-03 21:19:25 +03:00
Ivan Sorokin
c2a23f2265 use stats_alert in TorrentSpeedMonitor
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:35:27 +04:00
Ivan Sorokin
6f38616193 extract torrent statistics from torrent speed monitor to separate file 2014-06-02 00:31:45 +04:00
Ivan Sorokin
b50d7331c7 use post_status_update()
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:31:45 +04:00
Ivan Sorokin
eb46326d23 use set_alert_dispatch instead of timer to get an alerts from libtorrent
libtorrent allows setting a custom dispatch handler that is invoked in
libtorrent thread when new alerts are incoming. QAlertDispatcher is a
class that allows to translate these alerts to UI thread.

The concept is very simple:

1. On initialization QAlertDispatcher constructor calls set_alert_dispatch() passing
 QAlertDispatcher::dispatch as argument.

2. On deinitialization destructor calls set_alert_dispatch() passing a empty
 function. (line 25) libtorrent handles thos and switches back to queuing
 alerts in queue.

3. QAlertDispatcher::dispatch() adds alert to queue and notifies UI thread that new
 alerts are incoming. Enqueuing is done in function enqueueToMainThread().
 The invariant of class is the following:

    if alert queue is not empty, in message loop of UI thread contains a queued
    invocation of deliverSignal().

4. When message loop is pumped UI thread execute deliverSignal() function.
 It emit appropriate signal and if queue is still not empty (for example
 if slot doesn't grab alerts) rewind enqueuing to main thread.

This is a idea. But here is some details.

1. When QAlertDispatcher is destoyed, libtorrent still can call
QAlertDispatcher::dispatch a few times after destruction. This is
handled by passing a "tag". A tag is a object that references QAlertDispatch.
Tag could be invalidated. So on destruction QAlertDispatcher invalidates a tag
and then unsubscribes from alerts. When QAlertDispatcher::dispatch is called
with invalid tag it simply discard an alert.

    Therefore we could drop a few alerts during unsubscription. So we unsubscribe
    only at exit when missing some alerts is not a problem.

2. Another problem is in QBtSession::saveFastResumeData(). It pumps alert
queue synchronously. My first attempt was to destroy QAlertDispatcher
and then pump libtorrent queue. But as I was afraid of losing alerts I
supported synchronous querying of alerts in QAlertDispatcher.
(QAlertDispatcher::getPendingAlerts)

Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:31:45 +04:00
Ivan Sorokin
329b754197 cache torrent_status 2014-06-02 00:31:42 +04:00
Ivan Sorokin
1c98c11dd0 speed up icon loading 2014-05-25 12:32:09 +04:00
Ivan Sorokin
bbc4080a5d fewer calls to hash() 2014-05-25 12:32:09 +04:00
sledgehammer999
5d2663660d Count magnet links in the 'downloading' filter and make them prevent system inhibition. Closes #1558 2014-05-15 22:01:27 +03:00
sledgehammer999
659e0b7fef Fix tracker announcing problem(hit-and-run) when many torrents are being active. Closes #1571 2014-05-15 21:37:31 +03:00
sledgehammer999
9714b2ede9 Fix weird ratio values when torrent was imported or downloaded history was lost due to crash. 2014-05-05 21:30:15 +03:00
sledgehammer999
ef3f7d18c9 Fix compilation with Qt5. 2014-05-04 15:28:54 +03:00
Vladimir Golovnev (Glassez)
ce3aac5f9d Fix functions and macros using to support both Qt4 and Qt5. 2014-05-02 00:00:03 +03:00
sledgehammer999
77329a2609 Launch external programs async and don't block. Closes #1252. 2014-01-26 14:28:58 +02:00
sledgehammer999
79b3e5ab60 Merge pull request #1324 from Gelmir/rename_amount_columns
Use shorter names for amount columns in main UI
2014-01-25 15:48:40 -08:00
Nick Tiskov
1dd8fa3c58 Use shorter names for amount columns in main UI 2014-01-25 23:28:34 +04:00
sledgehammer999
8bbdcc78ce Statistics: handle case where user has gone back to older version. 2014-01-25 21:03:23 +02:00
Nick Tiskov
4390530cbe Update Main UI 2014-01-22 19:37:31 +04:00