Plugin and Content Manager: fix compil warnings and issues.

- some are Windows (msys2 ?) specific, related to curl.
- some others are shadowed or unused vars.
This commit is contained in:
jean-pierre charras 2021-08-28 10:32:47 +02:00
parent a1521d338e
commit a9829a598e
6 changed files with 24 additions and 16 deletions

View File

@ -22,6 +22,9 @@
* or you may write to the Free Software Foundation, Inc., * or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 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 <kicad_curl/kicad_curl_easy.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <build_version.h> #include <build_version.h>
@ -36,7 +39,6 @@
#include <tool/common_control.h> #include <tool/common_control.h>
#include <id.h> #include <id.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <kicad_curl/kicad_curl_easy.h>
#include <dialogs/dialog_configure_paths.h> #include <dialogs/dialog_configure_paths.h>
#include <eda_doc.h> #include <eda_doc.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>

View File

@ -25,7 +25,7 @@
#define KICAD_CURL_EASY_H_ #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 * 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 * before winsocks2.h inside curl and curl.h causes build warnings if included before and wxxxx.h
* *

View File

@ -18,12 +18,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// 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 "dialog_pcm.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "dialog_manage_repositories.h" #include "dialog_manage_repositories.h"
#include "grid_tricks.h" #include "grid_tricks.h"
#include "ki_exception.h" #include "ki_exception.h"
#include "kicad_curl/kicad_curl_easy.h"
#include "kicad_settings.h" #include "kicad_settings.h"
#include "pcm_task_manager.h" #include "pcm_task_manager.h"
#include "pgm_base.h" #include "pgm_base.h"

View File

@ -105,8 +105,6 @@ void PANEL_PACKAGES_VIEW::SetData( const std::vector<PACKAGE_VIEW_DATA>& aPackag
ClearData(); ClearData();
wxSizer* sizer = m_packageListWindow->GetSizer();
for( const PACKAGE_VIEW_DATA& data : aPackageData ) for( const PACKAGE_VIEW_DATA& data : aPackageData )
{ {
PANEL_PACKAGE* package_panel = PANEL_PACKAGE* package_panel =

View File

@ -18,10 +18,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// 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 "pcm.h"
#include "core/wx_stl_compat.h" #include "core/wx_stl_compat.h"
#include "kicad_build_version.h" #include "kicad_build_version.h"
#include "kicad_curl/kicad_curl_easy.h"
#include "paths.h" #include "paths.h"
#include "pgm_base.h" #include "pgm_base.h"
#include "picosha2.h" #include "picosha2.h"
@ -472,9 +475,9 @@ void PLUGIN_CONTENT_MANAGER::preparePackage( PCM_PACKAGE& aPackage )
auto parse_major_minor = []( const wxString& version ) auto parse_major_minor = []( const wxString& version )
{ {
wxStringTokenizer tokenizer( version, "." ); wxStringTokenizer tokenizer( version, "." );
int major = wxAtoi( tokenizer.GetNextToken() ); int ver_major = wxAtoi( tokenizer.GetNextToken() );
int minor = wxAtoi( tokenizer.GetNextToken() ); int ver_minor = wxAtoi( tokenizer.GetNextToken() );
return std::tuple<int, int>( major, minor ); return std::tuple<int, int>( ver_major, ver_minor );
}; };
if( parse_major_minor( ver.kicad_version ) > m_kicad_version ) if( parse_major_minor( ver.kicad_version ) > m_kicad_version )

View File

@ -17,9 +17,11 @@
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// 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 "pcm_task_manager.h"
#include "kicad_curl/kicad_curl_easy.h"
#include "paths.h" #include "paths.h"
#include "picosha2.h" #include "picosha2.h"
#include "reporter.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.AppendDir( "cache" );
file_path.SetFullName( wxString::Format( "%s_v%s.zip", aPackage.identifier, aVersion ) ); 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 ) [&aVersion]( const PACKAGE_VERSION& pv )
{ {
return pv.version == aVersion; 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() ) if( !wxDirExists( file_path.GetPath() )
&& !wxFileName::Mkdir( file_path.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) ) && !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; 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 ) if( code == CURLE_OK )
{ {
PCM_TASK install_task = [aPackage, aVersion, aRepositoryId, file_path, this]() 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 ) [&aVersion]( const PACKAGE_VERSION& pv )
{ {
return pv.version == aVersion; return pv.version == aVersion;
} ); } );
const boost::optional<wxString>& hash = pkgver->download_sha256; const boost::optional<wxString>& hash = get_pkgver->download_sha256;
bool hash_match = true; bool hash_match = true;
if( hash ) if( hash )
@ -100,7 +102,7 @@ void PCM_TASK_MANAGER::DownloadAndInstall( const PCM_PACKAGE& aPackage, const wx
if( extract( file_path.GetFullPath(), aPackage.identifier ) ) 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. // TODO register libraries.
} }
else else