Fixed a rare crash provoked by two factors:

* Fixed LSPDocumentClient::~LSPDocumentClient: It now explicitly calls `mDoc->unregisterClient(this);`. This ensures that whenever the client is destroyed—whether by the server shutting down or just the document closing—it cleanly detaches from the TextDocument.
* Fixed `TextDocument::notifyDocumentClosed` Iterator Invalidation: Since `onDocumentClosed` is called during a loop over `mClients`, and `LSPDocumentClient` now unregisters itself during that exact same loop, it was modifying the `mClients` `std::unordered_set` while it was being iterated (which is undefined behavior). I changed `notifyDocumentClosed` to iterate over a copy of the clients, safely allowing clients to unregister themselves when they receive the notification.
This commit is contained in:
Martín Lucas Golini
2026-03-13 01:00:46 -03:00
parent 3c782905da
commit aea26546b8
4 changed files with 31 additions and 13 deletions

View File

@@ -41,6 +41,7 @@ void LSPDocumentClient::setupFoldRangeService() {
LSPDocumentClient::~LSPDocumentClient() {
mDoc->getFoldRangeService().setProvider( nullptr );
mDoc->unregisterClient( this );
mDoc = nullptr;
UISceneNode* sceneNode = getUISceneNode();
if ( nullptr != sceneNode && 0 != mTag )