diff --git a/airdcpp/FavoriteManager.cpp b/airdcpp/FavoriteManager.cpp index 03e50fd3..b513abb8 100644 --- a/airdcpp/FavoriteManager.cpp +++ b/airdcpp/FavoriteManager.cpp @@ -422,6 +422,8 @@ bool FavoriteManager::addFavoriteHub(const FavoriteHubEntryPtr& aEntry) { favoriteHubs.push_back(aEntry); } + setConnectState(aEntry); + fire(FavoriteManagerListener::FavoriteHubAdded(), aEntry); save(); return true; @@ -429,14 +431,7 @@ bool FavoriteManager::addFavoriteHub(const FavoriteHubEntryPtr& aEntry) { void FavoriteManager::onFavoriteHubUpdated(const FavoriteHubEntryPtr& aEntry) { // Update the connect state in case the address was changed - auto client = ClientManager::getInstance()->getClient(aEntry->getServer()); - if (client) { - aEntry->setConnectState(client->isConnected() ? FavoriteHubEntry::STATE_CONNECTED : FavoriteHubEntry::STATE_CONNECTING); - aEntry->setCurrentHubToken(client->getClientId()); - } else { - aEntry->setCurrentHubToken(0); - aEntry->setConnectState(FavoriteHubEntry::STATE_DISCONNECTED); - } + setConnectState(aEntry); save(); fire(FavoriteManagerListener::FavoriteHubUpdated(), aEntry); @@ -1229,6 +1224,17 @@ void FavoriteManager::on(ClientManagerListener::ClientRedirected, const ClientPt onConnectStateChanged(aNewClient, FavoriteHubEntry::STATE_CONNECTING); } +void FavoriteManager::setConnectState(const FavoriteHubEntryPtr& aEntry) noexcept { + auto client = ClientManager::getInstance()->getClient(aEntry->getServer()); + if (client) { + aEntry->setConnectState(client->isConnected() ? FavoriteHubEntry::STATE_CONNECTED : FavoriteHubEntry::STATE_CONNECTING); + aEntry->setCurrentHubToken(client->getClientId()); + } else { + aEntry->setCurrentHubToken(0); + aEntry->setConnectState(FavoriteHubEntry::STATE_DISCONNECTED); + } +} + void FavoriteManager::onConnectStateChanged(const ClientPtr& aClient, FavoriteHubEntry::ConnectState aState) noexcept { auto hub = getFavoriteHubEntry(aClient->getHubUrl()); if (hub) { diff --git a/airdcpp/FavoriteManager.h b/airdcpp/FavoriteManager.h index 951e0054..28c0e6b5 100644 --- a/airdcpp/FavoriteManager.h +++ b/airdcpp/FavoriteManager.h @@ -226,6 +226,7 @@ class FavoriteManager : public Speaker, private HttpCon bool onHttpFinished(bool fromHttp) noexcept; void onConnectStateChanged(const ClientPtr& aClient, FavoriteHubEntry::ConnectState aState) noexcept; + void setConnectState(const FavoriteHubEntryPtr& aEntry) noexcept; // SettingsManagerListener void on(SettingsManagerListener::Load, SimpleXML& xml) noexcept { diff --git a/airdcpp/TrackableDownloadItem.cpp b/airdcpp/TrackableDownloadItem.cpp index 2e73d1e0..d2ee6d1d 100644 --- a/airdcpp/TrackableDownloadItem.cpp +++ b/airdcpp/TrackableDownloadItem.cpp @@ -25,6 +25,12 @@ namespace dcpp { + TrackableDownloadItem::~TrackableDownloadItem() { + if (hasDownloads()) { + DownloadManager::getInstance()->removeListener(this); + } + } + void TrackableDownloadItem::updateState() noexcept { State newState; { diff --git a/airdcpp/TrackableDownloadItem.h b/airdcpp/TrackableDownloadItem.h index 3f427435..4ab01484 100644 --- a/airdcpp/TrackableDownloadItem.h +++ b/airdcpp/TrackableDownloadItem.h @@ -32,6 +32,8 @@ namespace dcpp { virtual void onRemovedQueue(const string& aDir, bool aFinished) noexcept; virtual void onAddedQueue(const string& aDir) noexcept; + ~TrackableDownloadItem() noexcept; + enum State : uint8_t { STATE_DOWNLOAD_PENDING, STATE_DOWNLOADING, diff --git a/airdcpp/Updater.cpp b/airdcpp/Updater.cpp index 5002ed0d..5591d1c5 100644 --- a/airdcpp/Updater.cpp +++ b/airdcpp/Updater.cpp @@ -121,6 +121,8 @@ void Updater::createUpdate() { //add the theme folder auto installer = Util::getParentDir(updaterFilePath) + "installer" + PATH_SEPARATOR; ZipFile::CreateZipFileList(files, installer, Util::emptyString, "^(Themes)$"); + //Add the web-resources + ZipFile::CreateZipFileList(files, installer, Util::emptyString, "^(Web-resources)$"); ZipFile::CreateZipFile(updaterFilePath + updaterFile, files); diff --git a/airdcpp/ViewFileManager.cpp b/airdcpp/ViewFileManager.cpp index 6008fd5a..4fd41848 100644 --- a/airdcpp/ViewFileManager.cpp +++ b/airdcpp/ViewFileManager.cpp @@ -125,7 +125,7 @@ namespace dcpp { bool ViewFileManager::addFileNotify(const string& aFileName, int64_t aSize, const TTHValue& aTTH, const HintedUser& aUser, bool aIsText) noexcept { try { - if (ViewFileManager::getInstance()->addFileThrow(aFileName, aSize, aTTH, aUser, true)) { + if (ViewFileManager::getInstance()->addFileThrow(aFileName, aSize, aTTH, aUser, aIsText)) { return true; } @@ -145,21 +145,16 @@ namespace dcpp { return false; } - auto downloads = file->getDownloads(); - if (!downloads.empty()) { - // It will come back here after being removed from the queue - for (const auto& p : downloads) { - QueueManager::getInstance()->removeFile(p); - } - } else { - { - WLock l(cs); - viewFiles.erase(aTTH); - } + // In case it hasn't been removed yet + QueueManager::getInstance()->removeFile(file->getPath()); - fire(ViewFileManagerListener::FileClosed(), file); + { + WLock l(cs); + viewFiles.erase(aTTH); } + fire(ViewFileManagerListener::FileClosed(), file); + return true; }