[memory leak] make sure we only allow one GitHistoryPageSource instance
commitd453eefa1f83a53159f66a3cd2d64460f5cec00e
authorAndrey Loskutov <loskutov@gmx.de>
Mon, 2 May 2016 15:43:56 +0000 (2 17:43 +0200)
committerAndrey Loskutov <loskutov@gmx.de>
Wed, 4 May 2016 16:40:35 +0000 (4 11:40 -0500)
tree64440e07a66368347afd6e165a2db6ea461a3f0c
parentb7eb3ebb16528fdde6ad55da23dc0fd63aacf412
[memory leak] make sure we only allow one GitHistoryPageSource instance

This should fix the issue that we can have multiple GitHistoryPage
instances for same repository created and held by GenericHistoryView.

The code in PageBookView.getPageRec(IWorkbenchPart) uses map with the
part as a key to get appropriate page instance. In case an existing page
is not found, the
GenericHistoryView.showHistoryPageFor(Object,
boolean, boolean, IHistoryPageSource) creates a new "dummy"
HistoryPageSourceWorkbenchPart, which was used as a key in the map
above. In the hashCode() and equals() methods the
HistoryPageSourceWorkbenchPart uses hashCode() and equals() methods from
IHistoryPageSource instances. Previously it could happen that multiple
GitHistoryPageSource instances were created by the GitAdapterFactory
because the factory instances are created for each adapter contribution
in the plugin.xml, so that GitHistoryPageSource instances returned from
different GitAdapterFactory instances were different.

With different GitHistoryPageSource instances the
HistoryPageSourceWorkbenchPart keys were always different (even for the
same repository/file), the "old" existing GitHistoryPage instances were
not found, new pages were created by GenericHistoryView and old pages
left in memory (until closing the history view).

Bug: 492099
Change-Id: I451c39589994387998053c5d09074ebf69cca0a4
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPageSource.java