Code cleanup and compiler warnings.
(cherry picked from commit 51848a0b43
)
This commit is contained in:
parent
98cd040952
commit
4a561b04bc
|
@ -37,9 +37,15 @@
|
||||||
#include <wx/stdpaths.h>
|
#include <wx/stdpaths.h>
|
||||||
|
|
||||||
|
|
||||||
DIALOG_GIT_REPOSITORY::DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository* aRepository, wxString aURL ) :
|
DIALOG_GIT_REPOSITORY::DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository* aRepository,
|
||||||
DIALOG_GIT_REPOSITORY_BASE( aParent ), m_repository( aRepository ), m_prevFile( wxEmptyString ),
|
wxString aURL ) :
|
||||||
m_tested( 0 ), m_failedTest( false ), m_testError( wxEmptyString ), m_tempRepo( false ),
|
DIALOG_GIT_REPOSITORY_BASE( aParent ),
|
||||||
|
m_repository( aRepository ),
|
||||||
|
m_prevFile( wxEmptyString ),
|
||||||
|
m_tested( 0 ),
|
||||||
|
m_failedTest( false ),
|
||||||
|
m_testError( wxEmptyString ),
|
||||||
|
m_tempRepo( false ),
|
||||||
m_repoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL )
|
m_repoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL )
|
||||||
{
|
{
|
||||||
m_txtURL->SetFocus();
|
m_txtURL->SetFocus();
|
||||||
|
@ -50,7 +56,8 @@ DIALOG_GIT_REPOSITORY::DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository*
|
||||||
m_tempRepo = true;
|
m_tempRepo = true;
|
||||||
m_tempPath = wxFileName::CreateTempFileName( "kicadtestrepo" );
|
m_tempPath = wxFileName::CreateTempFileName( "kicadtestrepo" );
|
||||||
|
|
||||||
git_repository_init_options options = GIT_REPOSITORY_INIT_OPTIONS_INIT;
|
git_repository_init_options options;
|
||||||
|
options.version = GIT_REPOSITORY_INIT_OPTIONS_VERSION;
|
||||||
options.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_NO_REINIT;
|
options.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_NO_REINIT;
|
||||||
git_repository_init_ext( &m_repository, m_tempPath.ToStdString().c_str(), &options );
|
git_repository_init_ext( &m_repository, m_tempPath.ToStdString().c_str(), &options );
|
||||||
}
|
}
|
||||||
|
@ -90,8 +97,10 @@ bool DIALOG_GIT_REPOSITORY::extractClipboardData()
|
||||||
{
|
{
|
||||||
if( std::get<0>( isValidHTTPS( clipboardText ) )
|
if( std::get<0>( isValidHTTPS( clipboardText ) )
|
||||||
|| std::get<0>( isValidSSH( clipboardText ) ) )
|
|| std::get<0>( isValidSSH( clipboardText ) ) )
|
||||||
|
{
|
||||||
m_txtURL->SetValue( clipboardText );
|
m_txtURL->SetValue( clipboardText );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
@ -252,7 +261,8 @@ void DIALOG_GIT_REPOSITORY::updateURLData()
|
||||||
void DIALOG_GIT_REPOSITORY::OnTestClick( wxCommandEvent& event )
|
void DIALOG_GIT_REPOSITORY::OnTestClick( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
git_remote* remote = nullptr;
|
git_remote* remote = nullptr;
|
||||||
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
git_remote_callbacks callbacks;
|
||||||
|
callbacks.version = GIT_REMOTE_CALLBACKS_VERSION;
|
||||||
|
|
||||||
// We track if we have already tried to connect.
|
// We track if we have already tried to connect.
|
||||||
// If we have, the server may come back to offer another connection
|
// If we have, the server may come back to offer another connection
|
||||||
|
@ -362,7 +372,8 @@ void DIALOG_GIT_REPOSITORY::OnFileUpdated( wxFileDirPickerEvent& aEvent )
|
||||||
|
|
||||||
if( !isValid )
|
if( !isValid )
|
||||||
{
|
{
|
||||||
DisplayErrorMessage( this, _( "Invalid SSH Key" ), _( "The selected file is not a valid SSH private key" ) );
|
DisplayErrorMessage( this, _( "Invalid SSH Key" ),
|
||||||
|
_( "The selected file is not a valid SSH private key" ) );
|
||||||
CallAfter( [this] { SetRepoSSHPath( m_prevFile ); } );
|
CallAfter( [this] { SetRepoSSHPath( m_prevFile ); } );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +397,8 @@ void DIALOG_GIT_REPOSITORY::OnFileUpdated( wxFileDirPickerEvent& aEvent )
|
||||||
|
|
||||||
if( !pubIfs.good() || !pubIfs.is_open() )
|
if( !pubIfs.good() || !pubIfs.is_open() )
|
||||||
{
|
{
|
||||||
DisplayErrorMessage( this, wxString::Format( _( "Could not open public key '%s'" ), file + ".pub" ),
|
DisplayErrorMessage( this, wxString::Format( _( "Could not open public key '%s'" ),
|
||||||
|
file + ".pub" ),
|
||||||
wxString::Format( "%s: %d", std::strerror( errno ), errno ) );
|
wxString::Format( "%s: %d", std::strerror( errno ), errno ) );
|
||||||
aEvent.SetPath( wxEmptyString );
|
aEvent.SetPath( wxEmptyString );
|
||||||
CallAfter( [this] { SetRepoSSHPath( m_prevFile ); } );
|
CallAfter( [this] { SetRepoSSHPath( m_prevFile ); } );
|
||||||
|
@ -404,19 +416,22 @@ void DIALOG_GIT_REPOSITORY::OnOKClick( wxCommandEvent& event )
|
||||||
|
|
||||||
if( m_txtName->GetValue().IsEmpty() )
|
if( m_txtName->GetValue().IsEmpty() )
|
||||||
{
|
{
|
||||||
DisplayErrorMessage( this, _( "Missing information" ), _( "Please enter a name for the repository" ) );
|
DisplayErrorMessage( this, _( "Missing information" ),
|
||||||
|
_( "Please enter a name for the repository" ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_txtURL->GetValue().IsEmpty() )
|
if( m_txtURL->GetValue().IsEmpty() )
|
||||||
{
|
{
|
||||||
DisplayErrorMessage( this, _( "Missing information" ), _( "Please enter a URL for the repository" ) );
|
DisplayErrorMessage( this, _( "Missing information" ),
|
||||||
|
_( "Please enter a URL for the repository" ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EndModal( wxID_OK );
|
EndModal( wxID_OK );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_GIT_REPOSITORY::updateAuthControls()
|
void DIALOG_GIT_REPOSITORY::updateAuthControls()
|
||||||
{
|
{
|
||||||
if( m_ConnType->GetSelection() == static_cast<int>( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL ) )
|
if( m_ConnType->GetSelection() == static_cast<int>( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL ) )
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
class DIALOG_GIT_REPOSITORY : public DIALOG_GIT_REPOSITORY_BASE
|
class DIALOG_GIT_REPOSITORY : public DIALOG_GIT_REPOSITORY_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository* aRepository, wxString aURL = wxEmptyString );
|
DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository* aRepository,
|
||||||
|
wxString aURL = wxEmptyString );
|
||||||
~DIALOG_GIT_REPOSITORY() override;
|
~DIALOG_GIT_REPOSITORY() override;
|
||||||
|
|
||||||
void SetTestResult( bool aFailed, const wxString& aError )
|
void SetTestResult( bool aFailed, const wxString& aError )
|
||||||
|
@ -47,7 +48,10 @@ public:
|
||||||
updateAuthControls();
|
updateAuthControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
KIGIT_COMMON::GIT_CONN_TYPE GetRepoType() const { return static_cast<KIGIT_COMMON::GIT_CONN_TYPE>( m_ConnType->GetSelection() ); }
|
KIGIT_COMMON::GIT_CONN_TYPE GetRepoType() const
|
||||||
|
{
|
||||||
|
return static_cast<KIGIT_COMMON::GIT_CONN_TYPE>( m_ConnType->GetSelection() );
|
||||||
|
}
|
||||||
|
|
||||||
void SetRepoName( const wxString& aName ) { m_txtName->SetValue( aName ); }
|
void SetRepoName( const wxString& aName ) { m_txtName->SetValue( aName ); }
|
||||||
wxString GetRepoName() const { return m_txtName->GetValue(); }
|
wxString GetRepoName() const { return m_txtName->GetValue(); }
|
||||||
|
@ -106,6 +110,7 @@ private:
|
||||||
std::tuple<bool,wxString,wxString,wxString> isValidHTTPS( const wxString& url );
|
std::tuple<bool,wxString,wxString,wxString> isValidHTTPS( const wxString& url );
|
||||||
std::tuple<bool,wxString, wxString> isValidSSH( const wxString& url );
|
std::tuple<bool,wxString, wxString> isValidSSH( const wxString& url );
|
||||||
|
|
||||||
|
private:
|
||||||
git_repository* m_repository;
|
git_repository* m_repository;
|
||||||
|
|
||||||
wxString m_prevFile;
|
wxString m_prevFile;
|
||||||
|
@ -118,7 +123,6 @@ private:
|
||||||
wxString m_tempPath;
|
wxString m_tempPath;
|
||||||
|
|
||||||
KIGIT_COMMON::GIT_CONN_TYPE m_repoType;
|
KIGIT_COMMON::GIT_CONN_TYPE m_repoType;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DIALOG_GIT_REPOSITORY_H_ */
|
#endif /* DIALOG_GIT_REPOSITORY_H_ */
|
|
@ -55,7 +55,7 @@ void PANEL_GIT_REPOS::ResetPanel()
|
||||||
m_authorEmail->SetValue( wxEmptyString );
|
m_authorEmail->SetValue( wxEmptyString );
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::pair<wxString, wxString> getDefaultAuthorEmail()
|
static std::pair<wxString, wxString> getDefaultAuthorAndEmail()
|
||||||
{
|
{
|
||||||
wxString name;
|
wxString name;
|
||||||
wxString email;
|
wxString email;
|
||||||
|
@ -95,7 +95,7 @@ static std::pair<wxString, wxString> getDefaultAuthorEmail()
|
||||||
bool PANEL_GIT_REPOS::TransferDataFromWindow()
|
bool PANEL_GIT_REPOS::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
||||||
auto& repos = settings->m_Git.repositories;
|
std::vector<COMMON_SETTINGS::GIT_REPOSITORY>& repos = settings->m_Git.repositories;
|
||||||
|
|
||||||
repos.clear();
|
repos.clear();
|
||||||
|
|
||||||
|
@ -109,7 +109,8 @@ bool PANEL_GIT_REPOS::TransferDataFromWindow()
|
||||||
repo.authType = m_grid->GetCellValue( row, COL_AUTH_TYPE );
|
repo.authType = m_grid->GetCellValue( row, COL_AUTH_TYPE );
|
||||||
repo.username = m_grid->GetCellValue( row, COL_USERNAME );
|
repo.username = m_grid->GetCellValue( row, COL_USERNAME );
|
||||||
|
|
||||||
KIPLATFORM::SECRETS::StoreSecret( repo.path, repo.username, m_grid->GetCellValue( row, COL_PASSWORD ) );
|
KIPLATFORM::SECRETS::StoreSecret( repo.path, repo.username,
|
||||||
|
m_grid->GetCellValue( row, COL_PASSWORD ) );
|
||||||
repo.ssh_path = m_grid->GetCellValue( row, COL_SSH_PATH );
|
repo.ssh_path = m_grid->GetCellValue( row, COL_SSH_PATH );
|
||||||
repo.checkValid = m_grid->GetCellValue( row, COL_STATUS ) == "1";
|
repo.checkValid = m_grid->GetCellValue( row, COL_STATUS ) == "1";
|
||||||
repos.push_back( repo );
|
repos.push_back( repo );
|
||||||
|
@ -126,7 +127,8 @@ static bool testRepositoryConnection( COMMON_SETTINGS::GIT_REPOSITORY& repositor
|
||||||
{
|
{
|
||||||
git_libgit2_init();
|
git_libgit2_init();
|
||||||
|
|
||||||
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
git_remote_callbacks callbacks;
|
||||||
|
callbacks.version = GIT_REMOTE_CALLBACKS_VERSION;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -134,9 +136,13 @@ static bool testRepositoryConnection( COMMON_SETTINGS::GIT_REPOSITORY& repositor
|
||||||
bool success;
|
bool success;
|
||||||
} callbacksPayload;
|
} callbacksPayload;
|
||||||
|
|
||||||
callbacksPayload cb_data( { &repository, true } ); // If we don't need authentication, then, we are successful
|
callbacksPayload cb_data( { &repository, true } ); // If we don't need authentication, then,
|
||||||
|
// we are successful
|
||||||
callbacks.payload = &cb_data;
|
callbacks.payload = &cb_data;
|
||||||
callbacks.credentials = [](git_cred** out, const char* url, const char* username, unsigned int allowed_types, void* payload) -> int {
|
callbacks.credentials =
|
||||||
|
[](git_cred** out, const char* url, const char* username, unsigned int allowed_types,
|
||||||
|
void* payload) -> int
|
||||||
|
{
|
||||||
|
|
||||||
// If we are asking for credentials, then, we need authentication
|
// If we are asking for credentials, then, we need authentication
|
||||||
|
|
||||||
|
@ -179,7 +185,8 @@ static bool testRepositoryConnection( COMMON_SETTINGS::GIT_REPOSITORY& repositor
|
||||||
git_repository* repo = nullptr;
|
git_repository* repo = nullptr;
|
||||||
int result = git_repository_init( &repo, tempDirPath.mb_str( wxConvUTF8 ), 0 );
|
int result = git_repository_init( &repo, tempDirPath.mb_str( wxConvUTF8 ), 0 );
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0)
|
||||||
|
{
|
||||||
git_repository_free(repo);
|
git_repository_free(repo);
|
||||||
git_libgit2_shutdown();
|
git_libgit2_shutdown();
|
||||||
wxRmdir(tempDirPath);
|
wxRmdir(tempDirPath);
|
||||||
|
@ -188,7 +195,9 @@ static bool testRepositoryConnection( COMMON_SETTINGS::GIT_REPOSITORY& repositor
|
||||||
|
|
||||||
git_remote* remote = nullptr;
|
git_remote* remote = nullptr;
|
||||||
result = git_remote_create_anonymous( &remote, repo, tempDirPath.mb_str( wxConvUTF8 ) );
|
result = git_remote_create_anonymous( &remote, repo, tempDirPath.mb_str( wxConvUTF8 ) );
|
||||||
if (result != 0) {
|
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
git_remote_free(remote);
|
git_remote_free(remote);
|
||||||
git_repository_free(repo);
|
git_repository_free(repo);
|
||||||
git_libgit2_shutdown();
|
git_libgit2_shutdown();
|
||||||
|
@ -249,7 +258,7 @@ bool PANEL_GIT_REPOS::TransferDataToWindow()
|
||||||
|
|
||||||
if( settings->m_Git.useDefaultAuthor )
|
if( settings->m_Git.useDefaultAuthor )
|
||||||
{
|
{
|
||||||
auto defaultAuthor = getDefaultAuthorEmail();
|
std::pair<wxString, wxString> defaultAuthor = getDefaultAuthorAndEmail();
|
||||||
m_author->SetValue( defaultAuthor.first );
|
m_author->SetValue( defaultAuthor.first );
|
||||||
m_authorEmail->SetValue( defaultAuthor.second );
|
m_authorEmail->SetValue( defaultAuthor.second );
|
||||||
m_author->Disable();
|
m_author->Disable();
|
||||||
|
|
|
@ -1955,16 +1955,6 @@ static struct EDA_SHAPE_DESC
|
||||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||||
REGISTER_TYPE( EDA_SHAPE );
|
REGISTER_TYPE( EDA_SHAPE );
|
||||||
|
|
||||||
auto isNotPolygon =
|
|
||||||
[]( INSPECTABLE* aItem ) -> bool
|
|
||||||
{
|
|
||||||
// Polygons, unlike other shapes, have no meaningful start or end coordinates
|
|
||||||
if( EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( aItem ) )
|
|
||||||
return shape->GetShape() != SHAPE_T::POLY;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
auto isNotPolygonOrCircle = []( INSPECTABLE* aItem ) -> bool
|
auto isNotPolygonOrCircle = []( INSPECTABLE* aItem ) -> bool
|
||||||
{
|
{
|
||||||
// Polygons, unlike other shapes, have no meaningful start or end coordinates
|
// Polygons, unlike other shapes, have no meaningful start or end coordinates
|
||||||
|
|
|
@ -89,17 +89,6 @@ const std::map<GRAPHIC_PINSHAPE, struct pinShapeStruct> pinShapes = {
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
||||||
// bitmaps to show pins orientations in dialog editor
|
|
||||||
// must have same order than pin_orientation_names
|
|
||||||
static const BITMAPS iconsPinsOrientations[] =
|
|
||||||
{
|
|
||||||
BITMAPS::pinorient_right,
|
|
||||||
BITMAPS::pinorient_left,
|
|
||||||
BITMAPS::pinorient_up,
|
|
||||||
BITMAPS::pinorient_down,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
std::map<PIN_ORIENTATION, struct pinShapeStruct> pinOrientations = {
|
std::map<PIN_ORIENTATION, struct pinShapeStruct> pinOrientations = {
|
||||||
{ PIN_ORIENTATION::PIN_RIGHT, { _( "Right" ), BITMAPS::pinorient_right } },
|
{ PIN_ORIENTATION::PIN_RIGHT, { _( "Right" ), BITMAPS::pinorient_right } },
|
||||||
|
|
Loading…
Reference in New Issue