Properly cleanup git repos and memory on project/frame deletion
* Ensure the git backend is deleted when the project tree is deleted. * Unload the git repo for a project when the project is unloaded from the tree.
This commit is contained in:
parent
921358b096
commit
9456f35491
|
@ -33,6 +33,7 @@ class KIGIT_ERRORS
|
|||
public:
|
||||
|
||||
KIGIT_ERRORS() = default;
|
||||
virtual ~KIGIT_ERRORS() = default;
|
||||
|
||||
const std::vector<wxString>& GetErrorStrings() const
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ PROJECT_TREE::PROJECT_TREE( PROJECT_TREE_PANE* parent ) :
|
|||
m_statusImageList( nullptr )
|
||||
{
|
||||
m_projectTreePane = parent;
|
||||
m_gitCommon = new KIGIT_COMMON( nullptr );
|
||||
m_gitCommon = std::make_unique<KIGIT_COMMON>( nullptr );
|
||||
|
||||
// Make sure the GUI font scales properly on GTK
|
||||
SetFont( KIUI::GetControlFont( this ) );
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#ifndef PROJECT_TREE_H
|
||||
#define PROJECT_TREE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <git/kicad_git_common.h>
|
||||
|
||||
#include <wx/treectrl.h>
|
||||
|
@ -42,10 +44,10 @@ class PROJECT_TREE : public wxTreeCtrl
|
|||
DECLARE_DYNAMIC_CLASS( PROJECT_TREE )
|
||||
|
||||
private:
|
||||
PROJECT_TREE_PANE* m_projectTreePane;
|
||||
wxImageList* m_imageList;
|
||||
wxImageList* m_statusImageList;
|
||||
KIGIT_COMMON* m_gitCommon;
|
||||
PROJECT_TREE_PANE* m_projectTreePane;
|
||||
wxImageList* m_imageList;
|
||||
wxImageList* m_statusImageList;
|
||||
std::unique_ptr<KIGIT_COMMON> m_gitCommon;
|
||||
|
||||
public:
|
||||
PROJECT_TREE_PANE* GetProjectTreePane() const { return m_projectTreePane; }
|
||||
|
@ -58,7 +60,7 @@ public:
|
|||
void SetGitRepo( git_repository* aRepo ) { m_gitCommon->SetRepo( aRepo ); }
|
||||
git_repository* GetGitRepo() const { return m_gitCommon->GetRepo(); }
|
||||
|
||||
KIGIT_COMMON* GitCommon() const { return m_gitCommon; }
|
||||
KIGIT_COMMON* GitCommon() const { return m_gitCommon.get(); }
|
||||
|
||||
private:
|
||||
/* overridden sort function */
|
||||
|
|
|
@ -1482,6 +1482,13 @@ void PROJECT_TREE_PANE::EmptyTreePrj()
|
|||
shutdownFileWatcher();
|
||||
|
||||
m_TreeProject->DeleteAllItems();
|
||||
|
||||
// Remove the git repository when the project is unloaded
|
||||
if( m_TreeProject->GetGitRepo() )
|
||||
{
|
||||
git_repository_free( m_TreeProject->GetGitRepo() );
|
||||
m_TreeProject->SetGitRepo( nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue