Github plugin: fix lack of message when trying to download a non existing footprint library (Curl does not return an error: the message "Not Fount" is stored in buffer, and the zip handler returns a not suitable error message)

Minor and very minor other fixes.
This commit is contained in:
jean-pierre charras 2015-12-30 08:46:32 +01:00
parent ab585f46ce
commit 6ff0092e21
6 changed files with 35 additions and 23 deletions

View File

@ -62,7 +62,7 @@ void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
{
wxWindow* w = event.GetWindow();
for( unsigned i=0; i<DIM(m_player); ++i )
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
{
// if destroying one of our flock, then mark it as deceased.
if( (wxWindow*) m_player[i] == w )
@ -273,7 +273,7 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate )
{
// Since this will be called from python, cannot assume that code will
// not pass a bad aFrameType.
if( unsigned( aFrameType ) >= DIM( m_player ) )
if( unsigned( aFrameType ) >= KIWAY_PLAYER_COUNT )
{
// @todo : throw an exception here for python's benefit, at least that
// way it gets some explanatory text.
@ -316,7 +316,7 @@ bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
{
// Since this will be called from python, cannot assume that code will
// not pass a bad aFrameType.
if( unsigned( aFrameType ) >= DIM( m_player ) )
if( unsigned( aFrameType ) >= KIWAY_PLAYER_COUNT )
{
// @todo : throw an exception here for python's benefit, at least that
// way it gets some explanatory text.
@ -344,7 +344,7 @@ bool KIWAY::PlayersClose( bool doForce )
{
bool ret = true;
for( unsigned i=0; i < DIM( m_player ); ++i )
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
{
ret = ret && PlayerClose( FRAME_T( i ), doForce );
}
@ -383,7 +383,7 @@ void KIWAY::SetLanguage( int aLanguage )
}
#endif
for( unsigned i=0; i < DIM( m_player ); ++i )
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
{
KIWAY_PLAYER* frame = m_player[i];

View File

@ -101,11 +101,12 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
wxDefaultPosition, wxDefaultSize,
aFrameType==FRAME_SCH_VIEWER_MODAL ?
#ifdef __WINDOWS__
KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP :
KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP
#else
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT :
aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP
#endif
KICAD_DEFAULT_DRAWFRAME_STYLE,
: KICAD_DEFAULT_DRAWFRAME_STYLE,
aFrameType == FRAME_SCH_VIEWER_MODAL ?
LIB_VIEW_FRAME_NAME_MODAL : LIB_VIEW_FRAME_NAME )
{

View File

@ -95,7 +95,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
#ifdef __WINDOWS__
KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
#else
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT,
aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
#endif
FOOTPRINT_WIZARD_FRAME_NAME )
{

View File

@ -552,6 +552,16 @@ void GITHUB_PLUGIN::remoteGetZip( const wxString& aRepoURL ) throw( IO_ERROR )
THROW_IO_ERROR( msg );
}
// If the zip archive is not existing, the received data is "Not Found",
// and no error is returned by kcurl.Perform().
if( m_zip_image.compare( 0, 9, "Not Found" ) == 0 )
{
UTF8 fmt( _( "Cannot download library '%s'.\nThe library does not exist on the server" ) );
std::string msg = StrPrintf( fmt.c_str(), TO_UTF8( aRepoURL ) );
THROW_IO_ERROR( msg );
}
}
#if 0 && defined(STANDALONE)

View File

@ -142,6 +142,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
if( viewer )
viewer->Destroy();
// Creates the modal Lib browser:
viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
wxString fpid;
@ -149,8 +150,6 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
int ret = viewer->ShowModal( &fpid, this );
(void) ret; // make static analyser quiet
//DBG(printf("%s: fpid:'%s'\n", __func__, TO_UTF8( fpid ) );)
viewer->Destroy();
return fpid;

View File

@ -97,11 +97,11 @@ END_EVENT_TABLE()
/* Note:
* FOOTPRINT_VIEWER_FRAME can be build in "modal mode", or as a usual frame.
* FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
* In modal mode:
* a tool to export the selected footprint is shown in the toolbar
* the style is wxSTAY_ON_TOP on Windows and wxFRAME_FLOAT_ON_PARENT on unix
* reason:
* Reason:
* the parent is usually the kicad window manager (not easy to change)
* On windows, when the frame with stype wxFRAME_FLOAT_ON_PARENT is displayed
* its parent frame is brought to the foreground, on the top of the calling frame.
@ -109,7 +109,7 @@ END_EVENT_TABLE()
* this issue does not happen on unix
*
* So we use wxSTAY_ON_TOP on Windows, and wxFRAME_FLOAT_ON_PARENT on unix
* to simulate a dialog called by ShowModal.
* to force FOOTPRINT_VIEWER_FRAME to stay on parent when it is Modal.
*/
@ -122,12 +122,13 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
wxDefaultPosition, wxDefaultSize,
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ?
#ifdef __WINDOWS__
KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP :
KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP
#else
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT :
aParent ?
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP
#endif
KICAD_DEFAULT_DRAWFRAME_STYLE,
: KICAD_DEFAULT_DRAWFRAME_STYLE,
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ?
FOOTPRINT_VIEWER_FRAME_NAME_MODAL
: FOOTPRINT_VIEWER_FRAME_NAME )