mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Merge fixes from stable branches (libtorrent v0.15 related)
This commit is contained in:
parent
44fc86e7da
commit
ec3b749ef6
@ -1358,6 +1358,11 @@ void Bittorrent::enableLSD(bool b) {
|
|||||||
void Bittorrent::loadSessionState() {
|
void Bittorrent::loadSessionState() {
|
||||||
const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
|
const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
|
||||||
if(!QFile::exists(state_path)) return;
|
if(!QFile::exists(state_path)) return;
|
||||||
|
if(QFile(state_path).size() == 0) {
|
||||||
|
// Remove empty state file
|
||||||
|
QFile::remove(state_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
#if LIBTORRENT_VERSION_MINOR > 14
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
std::vector<char> in;
|
std::vector<char> in;
|
||||||
if (load_file(state_path.toLocal8Bit().constData(), in) == 0)
|
if (load_file(state_path.toLocal8Bit().constData(), in) == 0)
|
||||||
@ -1386,12 +1391,10 @@ void Bittorrent::saveSessionState() {
|
|||||||
bencode(std::back_inserter(out), session_state);
|
bencode(std::back_inserter(out), session_state);
|
||||||
file f;
|
file f;
|
||||||
error_code ec;
|
error_code ec;
|
||||||
if (f.open(state_path.toLocal8Bit().data(), file::write_only, ec)) {
|
if (!f.open(state_path.toLocal8Bit().constData(), file::write_only, ec)) return;
|
||||||
if (ec) {
|
if (ec) return;
|
||||||
file::iovec_t b = {&out[0], out.size()};
|
file::iovec_t b = {&out[0], out.size()};
|
||||||
f.writev(0, &b, 1, ec);
|
f.writev(0, &b, 1, ec);
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
entry session_state = s->state();
|
entry session_state = s->state();
|
||||||
boost::filesystem::ofstream out(state_path.toLocal8Bit().constData()
|
boost::filesystem::ofstream out(state_path.toLocal8Bit().constData()
|
||||||
|
@ -339,7 +339,10 @@ int main(int argc, char *argv[]){
|
|||||||
delete loader;
|
delete loader;
|
||||||
#endif
|
#endif
|
||||||
qDebug("Deleting app...");
|
qDebug("Deleting app...");
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
// XXX: Why does it crash on Windows in QWindowsVistaStyle destructor!?
|
||||||
delete app;
|
delete app;
|
||||||
|
#endif
|
||||||
qDebug("App was deleted! All good.");
|
qDebug("App was deleted! All good.");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user