From a9829a598e07da97e9360296e41541fe8d7772a0 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 28 Aug 2021 10:32:47 +0200 Subject: [PATCH] Plugin and Content Manager: fix compil warnings and issues. - some are Windows (msys2 ?) specific, related to curl. - some others are shadowed or unused vars. --- common/tool/common_control.cpp | 4 +++- include/kicad_curl/kicad_curl_easy.h | 2 +- kicad/pcm/dialogs/dialog_pcm.cpp | 5 ++++- kicad/pcm/dialogs/panel_packages_view.cpp | 2 -- kicad/pcm/pcm.cpp | 11 +++++++---- kicad/pcm/pcm_task_manager.cpp | 16 +++++++++------- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index 84b48120d4..b6b404e73d 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -22,6 +22,9 @@ * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +// kicad_curl_easy.h must be included before wxWidgets because on Windows (msys2), there are +// collision with wx headers and curl.h defs +#include #include #include @@ -36,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/include/kicad_curl/kicad_curl_easy.h b/include/kicad_curl/kicad_curl_easy.h index 0883a2b444..ce23767b99 100644 --- a/include/kicad_curl/kicad_curl_easy.h +++ b/include/kicad_curl/kicad_curl_easy.h @@ -25,7 +25,7 @@ #define KICAD_CURL_EASY_H_ /* - * KICAD_CURL_EASY.h must included before wxWidgets because on Windows, + * KICAD_CURL_EASY.h must be included before wxWidgets headers because on Windows, * kicad_curl.h does not include curl.h, because wxWidgets ends up including windows.h * before winsocks2.h inside curl and curl.h causes build warnings if included before and wxxxx.h * diff --git a/kicad/pcm/dialogs/dialog_pcm.cpp b/kicad/pcm/dialogs/dialog_pcm.cpp index 17cc7a56c5..b4d8f794e2 100644 --- a/kicad/pcm/dialogs/dialog_pcm.cpp +++ b/kicad/pcm/dialogs/dialog_pcm.cpp @@ -18,12 +18,15 @@ * with this program. If not, see . */ +// kicad_curl_easy.h **must be** included before any wxWidgets header to avoid conflicts +// at least on Windows/msys2 +#include "kicad_curl/kicad_curl_easy.h" + #include "dialog_pcm.h" #include "bitmaps.h" #include "dialog_manage_repositories.h" #include "grid_tricks.h" #include "ki_exception.h" -#include "kicad_curl/kicad_curl_easy.h" #include "kicad_settings.h" #include "pcm_task_manager.h" #include "pgm_base.h" diff --git a/kicad/pcm/dialogs/panel_packages_view.cpp b/kicad/pcm/dialogs/panel_packages_view.cpp index adc94e407d..81b359c93d 100644 --- a/kicad/pcm/dialogs/panel_packages_view.cpp +++ b/kicad/pcm/dialogs/panel_packages_view.cpp @@ -105,8 +105,6 @@ void PANEL_PACKAGES_VIEW::SetData( const std::vector& aPackag ClearData(); - wxSizer* sizer = m_packageListWindow->GetSizer(); - for( const PACKAGE_VIEW_DATA& data : aPackageData ) { PANEL_PACKAGE* package_panel = diff --git a/kicad/pcm/pcm.cpp b/kicad/pcm/pcm.cpp index ed092560df..0bd38dd357 100644 --- a/kicad/pcm/pcm.cpp +++ b/kicad/pcm/pcm.cpp @@ -18,10 +18,13 @@ * with this program. If not, see . */ +// kicad_curl_easy.h *must be* included before any wxWidgets header to avoid conflicts +// at least on Windows/msys2 +#include "kicad_curl/kicad_curl_easy.h" + #include "pcm.h" #include "core/wx_stl_compat.h" #include "kicad_build_version.h" -#include "kicad_curl/kicad_curl_easy.h" #include "paths.h" #include "pgm_base.h" #include "picosha2.h" @@ -472,9 +475,9 @@ void PLUGIN_CONTENT_MANAGER::preparePackage( PCM_PACKAGE& aPackage ) auto parse_major_minor = []( const wxString& version ) { wxStringTokenizer tokenizer( version, "." ); - int major = wxAtoi( tokenizer.GetNextToken() ); - int minor = wxAtoi( tokenizer.GetNextToken() ); - return std::tuple( major, minor ); + int ver_major = wxAtoi( tokenizer.GetNextToken() ); + int ver_minor = wxAtoi( tokenizer.GetNextToken() ); + return std::tuple( ver_major, ver_minor ); }; if( parse_major_minor( ver.kicad_version ) > m_kicad_version ) diff --git a/kicad/pcm/pcm_task_manager.cpp b/kicad/pcm/pcm_task_manager.cpp index 4ccc769e3e..0d24ec1b10 100644 --- a/kicad/pcm/pcm_task_manager.cpp +++ b/kicad/pcm/pcm_task_manager.cpp @@ -17,9 +17,11 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ +// kicad_curl_easy.h **must be** included before any wxWidgets header to avoid conflicts +// at least on Windows/msys2 +#include "kicad_curl/kicad_curl_easy.h" #include "pcm_task_manager.h" -#include "kicad_curl/kicad_curl_easy.h" #include "paths.h" #include "picosha2.h" #include "reporter.h" @@ -46,13 +48,13 @@ void PCM_TASK_MANAGER::DownloadAndInstall( const PCM_PACKAGE& aPackage, const wx file_path.AppendDir( "cache" ); file_path.SetFullName( wxString::Format( "%s_v%s.zip", aPackage.identifier, aVersion ) ); - auto pkgver = std::find_if( aPackage.versions.begin(), aPackage.versions.end(), + auto find_pkgver = std::find_if( aPackage.versions.begin(), aPackage.versions.end(), [&aVersion]( const PACKAGE_VERSION& pv ) { return pv.version == aVersion; } ); - wxASSERT_MSG( pkgver != aPackage.versions.end(), "Package version not found" ); + wxASSERT_MSG( find_pkgver != aPackage.versions.end(), "Package version not found" ); if( !wxDirExists( file_path.GetPath() ) && !wxFileName::Mkdir( file_path.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) ) @@ -61,19 +63,19 @@ void PCM_TASK_MANAGER::DownloadAndInstall( const PCM_PACKAGE& aPackage, const wx return; } - int code = downloadFile( file_path.GetFullPath(), pkgver->download_url.get() ); + int code = downloadFile( file_path.GetFullPath(), find_pkgver->download_url.get() ); if( code == CURLE_OK ) { PCM_TASK install_task = [aPackage, aVersion, aRepositoryId, file_path, this]() { - auto pkgver = std::find_if( aPackage.versions.begin(), aPackage.versions.end(), + auto get_pkgver = std::find_if( aPackage.versions.begin(), aPackage.versions.end(), [&aVersion]( const PACKAGE_VERSION& pv ) { return pv.version == aVersion; } ); - const boost::optional& hash = pkgver->download_sha256; + const boost::optional& hash = get_pkgver->download_sha256; bool hash_match = true; if( hash ) @@ -100,7 +102,7 @@ void PCM_TASK_MANAGER::DownloadAndInstall( const PCM_PACKAGE& aPackage, const wx if( extract( file_path.GetFullPath(), aPackage.identifier ) ) { - m_pcm->MarkInstalled( aPackage, pkgver->version, aRepositoryId ); + m_pcm->MarkInstalled( aPackage, get_pkgver->version, aRepositoryId ); // TODO register libraries. } else