diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 546d7a6404..13b5ab82dc 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -304,6 +304,7 @@ public: _network_content_client.Connect(); } + /** Remove us from the content client's callbacks. */ ~BootstrapEmscripten() override { _network_content_client.RemoveCallback(this); diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index e36ab33d99..bda5af0556 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -175,6 +175,7 @@ public: this->vscroll->SetCount(this->bridges.size()); } + /** Save the last sorting state. */ ~BuildBridgeWindow() override { BuildBridgeWindow::last_sorting = this->bridges.GetListing(); diff --git a/src/command_func.h b/src/command_func.h index ec7f1730ef..c7b85393b7 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -57,7 +57,9 @@ static constexpr inline DoCommandFlags CommandFlagsToDCFlags(CommandFlags cmd_fl /** Helper class to keep track of command nesting level. */ struct RecursiveCommandCounter { + /** Increment the recursion counter. */ RecursiveCommandCounter() noexcept { _counter++; } + /** Decrement the recursion counter. */ ~RecursiveCommandCounter() noexcept { _counter--; } /** diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 41a90c6ee2..cf89cc747c 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -79,7 +79,7 @@ Company::Company(CompanyID index, StringID name_1, bool is_ai) : CompanyPool::Po InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, CompanyID::Invalid()); } -/** Destructor. */ +/** Close the associated company windows. */ Company::~Company() { if (CleaningPool()) return; diff --git a/src/debug.h b/src/debug.h index 18055d94c3..183c084c6a 100644 --- a/src/debug.h +++ b/src/debug.h @@ -86,6 +86,7 @@ struct TicToc { GetStates().push_back(this); } + /** Remove ourselves from the thread local states. */ ~State() { /* Container might be already destroyed. */ @@ -111,6 +112,7 @@ struct TicToc { inline TicToc(State &state) : state(state), chrono_start(std::chrono::high_resolution_clock::now()) { } + /** Update the state with the time since the constructor call. */ inline ~TicToc() { this->state.chrono_sum += (std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - this->chrono_start)).count(); diff --git a/src/depot.cpp b/src/depot.cpp index a69be5fe59..3dea62971c 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -23,7 +23,7 @@ DepotPool _depot_pool("Depot"); INSTANTIATE_POOL_METHODS(Depot) /** - * Clean up a depot + * Remove any references to this depot. */ Depot::~Depot() { diff --git a/src/economy.cpp b/src/economy.cpp index 0551132d0c..5ecf68d549 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1172,6 +1172,7 @@ CargoPayment::CargoPayment(CargoPaymentID index, Vehicle *front) : { } +/** Execute the actual payment to the coffers of the company. */ CargoPayment::~CargoPayment() { if (CleaningPool()) return; diff --git a/src/fontcache.h b/src/fontcache.h index e713cdf46f..a9f2b26ab9 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -237,6 +237,7 @@ public: ProviderManager::Register(*this); } + /** Unregister this factory. */ ~FontCacheFactory() override { ProviderManager::Unregister(*this); diff --git a/src/fontcache/freetypefontcache.cpp b/src/fontcache/freetypefontcache.cpp index e995576ed1..b2c1fccd36 100644 --- a/src/fontcache/freetypefontcache.cpp +++ b/src/fontcache/freetypefontcache.cpp @@ -213,6 +213,7 @@ class FreeTypeFontCacheFactory : public FontCacheFactory { public: FreeTypeFontCacheFactory() : FontCacheFactory("freetype", "FreeType font provider") {} + /** Close the freetype library. */ ~FreeTypeFontCacheFactory() override { FT_Done_FreeType(_ft_library); diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 13fafc5fd3..413e239de2 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -37,6 +37,7 @@ Gamelog::Gamelog() this->current_action = nullptr; } +/** Needs to be manually defined due to incomplete definition of GamelogInternalData in the header. */ Gamelog::~Gamelog() { } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index af4228663f..0af22612f5 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -449,6 +449,7 @@ public: this->SortVehicleList(); } + /** Save the last sorting state. */ ~VehicleGroupWindow() { *this->sorting = this->vehgroups.GetListing(); diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 05cd61abb2..efc2d26c8a 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -257,6 +257,7 @@ HotkeyList::HotkeyList(const std::string &ini_group, const std::vector & _hotkey_lists->push_back(this); } +/** Remove outselves from the global hotkey list. */ HotkeyList::~HotkeyList() { _hotkey_lists->erase(std::ranges::find(*_hotkey_lists, this)); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 7009a1809c..4f7d71735a 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -143,6 +143,7 @@ const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx) return &_industry_tile_specs[gfx]; } +/** Remove any reference to this industry from the game. */ Industry::~Industry() { if (CleaningPool()) return; diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index e295cd3c0d..946c1842eb 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -821,6 +821,7 @@ public: this->InvalidateData(); } + /** Close the industry production window. */ ~IndustryViewWindow() override { CloseWindowById(WC_INDUSTRY_PRODUCTION, this->window_number, false); @@ -1656,6 +1657,7 @@ public: this->industry_editbox.cancel_button = QueryString::ACTION_CLEAR; } + /** Save the last sorting state. */ ~IndustryDirectoryWindow() override { this->last_sorting = this->industries.GetListing(); diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp index a97e128a55..9503038666 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -1189,7 +1189,7 @@ std::optional MusicDriver_DMusic::Start(const StringList &parm return std::nullopt; } - +/** Stop the playing of the music. */ MusicDriver_DMusic::~MusicDriver_DMusic() { this->Stop(); diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp index 60dffc33d2..97c284b3cb 100644 --- a/src/music/midifile.cpp +++ b/src/music/midifile.cpp @@ -1130,6 +1130,7 @@ MidiFile::MidiFile() RegisterConsoleMidiCommands(); } +/** Remove ourselves from the _midifile_instance if needed. */ MidiFile::~MidiFile() { if (_midifile_instance == this) { diff --git a/src/network/core/http_curl.cpp b/src/network/core/http_curl.cpp index 8ede8b8413..e87cd4be18 100644 --- a/src/network/core/http_curl.cpp +++ b/src/network/core/http_curl.cpp @@ -67,6 +67,7 @@ public: _new_http_callbacks.push_back(&this->callback); } + /** Remove ourselves from the callback list. */ ~NetworkHTTPRequest() { std::lock_guard lock(_http_callback_mutex); diff --git a/src/network/core/http_shared.h b/src/network/core/http_shared.h index 2169efd34e..95269dc114 100644 --- a/src/network/core/http_shared.h +++ b/src/network/core/http_shared.h @@ -99,6 +99,7 @@ public: HTTPThreadSafeCallback(HTTPCallback *callback) : callback(callback) {} + /** Ensure our queues are emptied while holding a lock. */ ~HTTPThreadSafeCallback() { std::lock_guard lock(this->mutex); diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index ad624c12f1..dd02c8b788 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -14,6 +14,7 @@ #include "../../safeguards.h" +/** Close the socket. */ NetworkTCPSocketHandler::~NetworkTCPSocketHandler() { this->CloseSocket(); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 6c8806e82a..37f1b617e8 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -465,6 +465,7 @@ public: this->servers.ForceRebuild(); } + /** Save the last sorting state. */ ~NetworkGameWindow() override { this->last_sorting = this->servers.GetListing(); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 75506e0861..747e206063 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -80,7 +80,7 @@ struct PacketWriter : SaveFilter { { } - /** Make sure everything is cleaned up. */ + /** Make sure everything is cleaned up under lock. */ ~PacketWriter() override { std::unique_lock lock(this->mutex); diff --git a/src/network/network_stun.cpp b/src/network/network_stun.cpp index c174d824a2..d4c4248cfc 100644 --- a/src/network/network_stun.cpp +++ b/src/network/network_stun.cpp @@ -118,6 +118,7 @@ NetworkRecvStatus ClientNetworkStunSocketHandler::CloseConnection(bool error) return NETWORK_RECV_STATUS_OKAY; } +/** Stop the attempt to connect. */ ClientNetworkStunSocketHandler::~ClientNetworkStunSocketHandler() { if (this->connecter != nullptr) { diff --git a/src/network/network_turn.cpp b/src/network/network_turn.cpp index 9f140fc95a..bc57856fa9 100644 --- a/src/network/network_turn.cpp +++ b/src/network/network_turn.cpp @@ -125,6 +125,7 @@ NetworkRecvStatus ClientNetworkTurnSocketHandler::CloseConnection(bool error) return NETWORK_RECV_STATUS_OKAY; } +/** Stop the attempt to connect. */ ClientNetworkTurnSocketHandler::~ClientNetworkTurnSocketHandler() { if (this->connecter != nullptr) { diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index 1f6f75e364..9c6843a05e 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -95,6 +95,7 @@ Win32FontCache::Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels) this->SetFontSize(pixels); } +/** Release all the operating system objects. */ Win32FontCache::~Win32FontCache() { this->ClearFontCache(); diff --git a/src/screenshot_type.h b/src/screenshot_type.h index 480aa7707a..1439a303ed 100644 --- a/src/screenshot_type.h +++ b/src/screenshot_type.h @@ -31,6 +31,7 @@ public: ProviderManager::Register(*this); } + /** Unregister ourselves from the screenshot providers. */ ~ScreenshotProvider() override { ProviderManager::Unregister(*this); diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index b5848faefb..4fc9630f81 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -783,6 +783,7 @@ struct ScriptDebugWindow : public Window { this->InvalidateData(-1); } + /** Save the last sorting state. */ ~ScriptDebugWindow() override { ScriptDebugWindow::initial_state = this->filter; diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 25769d7246..97ee44188b 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -160,6 +160,7 @@ public: if (this->allocation_limit == 0) this->allocation_limit = SAFE_LIMIT; // in case the setting is somehow zero } + /** Ensure the allocations have already been released. */ ~ScriptAllocator() { #ifdef SCRIPT_DEBUG_ALLOCATIONS @@ -735,6 +736,7 @@ bool Squirrel::LoadScript(const std::string &script) return LoadScript(this->vm, script); } +/** Clean up the Squirrel virtual machine state. */ Squirrel::~Squirrel() { this->Uninitialize(); diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index fdf7b0f24c..ca15f8c093 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -434,6 +434,7 @@ public: _squirrel_allocator = engine != nullptr ? engine->allocator.get() : nullptr; } + /** Restore the previous allocator. */ ~ScriptAllocatorScope() { _squirrel_allocator = this->old_allocator; diff --git a/src/settings.cpp b/src/settings.cpp index 58bc1ab8bb..63e90e7f44 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2034,6 +2034,7 @@ ScriptConfigSettings::ScriptConfigSettings() /* Instantiate here, because unique_ptr needs a complete type. */ } +/** Needs to be manually defined due to incomplete definition of types in the header. */ ScriptConfigSettings::~ScriptConfigSettings() { /* Instantiate here, because unique_ptr needs a complete type. */ diff --git a/src/soundloader_type.h b/src/soundloader_type.h index 2b4d776a94..1353abe9e0 100644 --- a/src/soundloader_type.h +++ b/src/soundloader_type.h @@ -21,6 +21,7 @@ public: ProviderManager::Register(*this); } + /** Unregister this sound loader. */ ~SoundLoader() override { ProviderManager::Unregister(*this); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index cdc9464872..5d93365c31 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -443,6 +443,7 @@ public: this->GetWidget(WID_STL_SORTDROPBTN)->SetString(CompanyStationsWindow::sorter_names[this->stations.SortType()]); } + /** Save the last sorting state. */ ~CompanyStationsWindow() override { /* Save filter state. */ @@ -1088,6 +1089,7 @@ CargoDataEntry::CargoDataEntry(CargoType cargo) : children(nullptr) {} +/** Remove ourselves from our parent. */ CargoDataEntry::~CargoDataEntry() { this->Clear(); diff --git a/src/story.cpp b/src/story.cpp index ddfbcec7cd..8558450c35 100644 --- a/src/story.cpp +++ b/src/story.cpp @@ -37,6 +37,7 @@ StoryPagePool _story_page_pool("StoryPage"); INSTANTIATE_POOL_METHODS(StoryPageElement) INSTANTIATE_POOL_METHODS(StoryPage) +/** Delete all of our StoryPageElements. */ StoryPage::~StoryPage() { if (CleaningPool()) return; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 30b892b0ae..bd86195723 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1965,6 +1965,7 @@ public: this->SortVehicleList(); } + /** Save the last sorting state. */ ~VehicleListWindow() override { *this->sorting = this->vehgroups.GetListing(); diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp index 6f7d72248f..49c724a8bc 100644 --- a/src/video/opengl.cpp +++ b/src/video/opengl.cpp @@ -1476,6 +1476,7 @@ OpenGLSprite::OpenGLSprite(SpriteType sprite_type, const SpriteLoader::SpriteCol assert(_glGetError() == GL_NO_ERROR); } +/** Delete the textures we allocated. */ OpenGLSprite::~OpenGLSprite() { _glDeleteTextures(NUM_TEX, this->tex.data()); diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index 96cda42ce7..d846498222 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -213,11 +213,13 @@ public: * will make sure the buffer is unlocked no matter how the scope is exited. */ struct VideoBufferLocker { + /** Lock the video buffer. */ VideoBufferLocker() { this->unlock = VideoDriver::GetInstance()->LockVideoBuffer(); } + /** Release the video buffer. */ ~VideoBufferLocker() { if (this->unlock) VideoDriver::GetInstance()->UnlockVideoBuffer(); diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 2f2def12dd..84e1d0e934 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -42,6 +42,7 @@ TileArea Waypoint::GetTileArea(StationType type) const } } +/** Remove all references to this waypoint. */ Waypoint::~Waypoint() { if (CleaningPool()) return; diff --git a/src/window.cpp b/src/window.cpp index 763d9c1425..bf39c5f8ec 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -136,6 +136,7 @@ WindowDesc::WindowDesc(WindowPosition def_pos, std::string_view ini_key, int16_t _window_descs->push_back(this); } +/** Remove ourselves from the global list of window descs. */ WindowDesc::~WindowDesc() { _window_descs->erase(std::ranges::find(*_window_descs, this));