https://bugs.kde.org/show_bug.cgi?id=486949
--- Comment #15 from Igor Kushnir <igor...@gmail.com> --- Git commit c68593429384cccd05c893ce7ddef7c7e0cde4e2 by Igor Kushnir. Committed on 12/03/2025 at 15:49. Pushed by igorkushnir into branch 'master'. Unregister repositories for current branch changes When a project with an IBranchingVersionControl version control plugin (Git or Mercurial) is opened, its path is registered for current branch changes. GitPlugin::registerRepositoryForCurrentBranchChanges() adds the HEAD file of each registered git repository to a KDirWatch. However, when a project is closed, its path is not unregistered and remains watched by the KDirWatch. Unregister a closed project's path to properly clean up and optimize. Also unregister the paths of all still-open projects when a registrant (a listener to the signal repositoryBranchChanged()) is destroyed. Multiple listeners register the same opened project path: ProjectChangesModel, RepoStatusModel (this one failed to register before now) and VcsOverlayProxyModel. Therefore, robust unregistering requires adding a listener parameter to the functions (un)registerRepositoryForCurrentBranchChanges() and storing lists of listeners in GitPlugin. Otherwise, if a listener unregisters a path, which it has not registered before, another listener may miss current branch updates. At this time, the elaborate (un)registering is not very useful because ProjectController::initialize() unconditionally creates the ProjectChangesModel instance, which unconditionally registers all IBranchingVersionControl project repositories and remains alive until KDevelop exit (incidentally, the late destruction prevents ~ProjectChangesModel() from unregistering all still-open projects). Similarly, RepoStatusModel exists as long as its parent GitPlugin is alive. Due to KDevelop UI freezes caused by background work of ProjectChangesModel and RepoStatusModel (manifested in Bug 486949), subsequent commits will make sure that the instance of each of the two classes exists only as long as its tool view is present in the UI. And then the diligent unregistering will prevent useless work when all listeners to the signal repositoryBranchChanged() are destroyed. RepoStatusModel fails to register project repositories for current branch changes. Correct this omission to prevent bugs when a subsequent commit makes the ProjectChangesModel instance optional and prevents it from reliably registering all repositories. GitPlugin::fileChanged() emits the signal repositoryBranchChanged() with a 1-second delay because the HEAD file is modified while the git repository is still being updated and is not yet ready for use. When a git rebase process quickly applies commits one after another, multiple changes to the HEAD file occur within this 1-second interval. The slow handling by the listeners of the multiple accumulated and emitted repositoryBranchChanged() signals can freeze the KDevelop UI from the 1 second after the beginning of the rebase operation until several seconds after the operation's completion. Each of these emitted signals reports a current branch change of the same git repository, so the listeners perform essentially the same work over and over again, and overwrite previous results in response to each emission. Store a timer per watched HEAD file and restart it instead of starting a new one when the file is changed before the 1-second timeout. This effectively compresses multiple close-by signals into one. Now the UI freeze (if noticeable at all) starts a second after the completion of the rebase operation and usually lasts less than a second. M +11 -2 kdevplatform/project/projectchangesmodel.cpp M +10 -5 kdevplatform/vcs/interfaces/ibranchingversioncontrol.h M +109 -10 plugins/git/gitplugin.cpp M +71 -2 plugins/git/gitplugin.h M +16 -2 plugins/git/repostatusmodel.cpp M +16 -1 plugins/projectmanagerview/vcsoverlayproxymodel.cpp M +1 -0 plugins/projectmanagerview/vcsoverlayproxymodel.h https://invent.kde.org/kdevelop/kdevelop/-/commit/c68593429384cccd05c893ce7ddef7c7e0cde4e2 -- You are receiving this mail because: You are watching all bug changes.