qbittorrent/qBittorrent — pull request #1809 by sledgehammer999 (2014-07-05 19:09:03+00:00)
Title: Memory caching

Now the preferences class accesses the qbittorrent.ini/qbittorrent.conf file only when needed and caches the values in memory. No need to re-read the file for the same value. Ideally it should read the file once upon startup and write to it once upon exit.

Changes are accumulated and only written out after 15mins. If there aren't any changes nothing is written.
The exception is when the user has open the Options' window and changed something. In this case the changes are saved instantly.

There is also a safety feature in case of power outage or in case the disk is full when trying to write the settings. Now the settings are written first in a file named `qBittorrent_new.ini`/`qBittorrent_new.conf` and if everything went well, qBittorrent.ini is deleted and qBittorrent_new takes its place. Upon startup if qBittorrent_new exists it is used because it is assumed that something bad happened during shutdown and it probably contains the most recent changes.

Much other code touched qBittorrent.ini directly and not through the preferences class. This is a big problem if you want to take a uniform approach on handling the file and making sure that it doesn't get corrupt and the values stay in sync. So everything that needs access to qbittorrent.ini must go through the preferences class.

Since everything is in memory now, any GUI slowdowns related to this should be extinct. However, I don't know what is the overhead of the get()/set() methods since they use a Read/Write lock. It shouldn't be noticeable.

This is up for discussion. It will be merged after @glassez finishes the WebUI work or enough time has passed without activity from him. I have the responsibility to keep this current with master.