We need to be careful when using the multi-arg version of
QString::arg() and passing as 2nd, 3rd etc parameter an int.
It doesn't do the same as passing multiple QStrings.
Libtorrent can recheck only unpaused torrents. We get around this by
unpausing the torrent, issuing the recheck and pausing again after we
get alerted by libtorrent that the recheck has finished. This alert is
asyncronous. There is a small time frame where the program might start
downloading and writing data to the file before we pause it. This can
lead to data corruption if the file on disk is totally different that
the one expected by the torrent AND the file on disk is a valid file on
its own. OR in case the user points the new torrent to the wrong
directory by mistake.
To get around this the torrent is placed in upload_mode and out of
automanagement.
Using iostream usually adds a lot of other operators (<<, endl), whereas
*printf takes only 1 function call.
Also use qUtf8Printable whenever possible.
Many sites include various HTML entities in the content of RSS feeds.
The most of these entities are not declared in the underlying XML,
so the documents are considered by parser to be malformed.
This patch allows you to successfully parse such soft-malformed
RSS feeds.
Closes#8527.
Closes#8569.
Stops temporary containers being created needlessly due to API misuse.
For example, it’s common for developers to assume QHash::values() and
QHash::keys() are free and abuse them, failing to realize their
implementation internally actually iterates the whole container, allocates
memory, and fills a new QList.
Added a removeIf generic algorithm, similar to std ones. We can't use std
algorithms with Qt dictionaries because Qt iterators have different
behavior from the std ones.
Found using clazy.
For some reason, the RSS feed may contain malformed XML data and it may not be
successfully parsed by the XML parser. We are still trying to load as many articles
as possible until we encounter corrupted data. So we can have some articles even in
case of parsing error.
Closes#8527.
Closes#8569.
Avoid temporary string allocations. They are only used to convert to
something else.
QString::xxxRef() returns a QStringRef. QStringRef avoids the memory
allocation and reference counting overhead of a standard QString by simply
referencing a part of the original string.
Legacy SearchEngine class really has three roles:
1. Manage search plugins,
2. Handle the search job, and
3. Handle the download of the torrent file using the search plugin.
Now it is splitted into 3 classes: SearchManager, SearchHandler and
SearchDownloadHandler.
Search GUI is also improved.
* Add more checks and also more strict checks for invalid conditions
* Add http version field
* Raise max request size to 64 MB
* Add author in license
* Use Qt5 new connect syntax
`torrent_info` constructor has default limits that can't be changed via
parameters, so we handle the loading process manually and explicitly
specifiy the limits to `bdecode()`.
The token_limit is also changed to 10000000.
Explicit or implicit calls to begin() and end() cause a non-const
container to detach from shared data, ie. to perform a deep-copy to gain
a unique copy of the data.
That can be a expensive although unneeded operation.
In order to assist the developer a copyAsConst function is added.
copyAsConst returns a const copy of the object.
For lvalues just use qAsConst. It's only available on Qt 5.7.0. But we
added also for earlier versions. The developer can always use qAsConst.
Intended uses:
QString s = ...;
for (const auto &ch : qAsConst(s))
process(ch);
for (const auto &ch : copyAsConst(funcReturningQString()))
process(ch);
It prevents detachments:
To illustrate:
QMap<QString, QString> map;
/* code compiles and works fine but find() returns the non-const
QMap::iterator that detaches!
*/
QMap<QString, QString>::const_iterator it = map.find("girish");
but also some subtle bugs:
QHash<int, int> wrong;
if (wrong.find(1) == wrong.cend()) {
qDebug() << "Not found";
} else {
/* find() detached the container before cend() was called, so it
prints "Found"
*/
qDebug() << "Found";
}
QHash<int, int> right;
if (right.constFind(1) == right.cend()) {
qDebug() << "Not found"; // This is correct now !
} else {
qDebug() << "Found";
}
Enforced by QT_STRICT_ITERATORS definition.