From 169905d26e344b2cbef37d9c6e65e03e0a594a26 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 7 Jul 2015 19:49:03 +0200 Subject: [PATCH] Drc dialog: fix some issues, and mainly the fact the progress bar shown during track tests and zone filling can be sent to the background and the dialog can be closed during tests or the board edited during tests. Add a minor change in dialog_shim only for OSX. (force raising the dialog). Very minot other fixes: coverity warnings, better message in debug mode in baord outlines calculations. --- common/dialog_shim.cpp | 3 ++ common/geometry/shape_collisions.cpp | 6 ++++ pcbnew/drc.cpp | 3 +- pcbnew/legacy_plugin.cpp | 2 ++ pcbnew/specctra_export.cpp | 38 +++++++++++----------- pcbnew/zones_by_polygon_fill_functions.cpp | 4 ++- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 881fb479f9..d1dcfb6d15 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -112,6 +112,9 @@ bool DIALOG_SHIM::Show( bool show ) if( show ) { ret = wxDialog::Show( show ); +#ifdef __WXMAC__ + wxDialog::Raise(); // More wxWindows brokenness on OS X +#endif // classname is key, returns a zeroed out default EDA_RECT if none existed before. EDA_RECT r = class_map[ hash_key ]; diff --git a/common/geometry/shape_collisions.cpp b/common/geometry/shape_collisions.cpp index 92442cbe2e..1cf0f2f7c0 100644 --- a/common/geometry/shape_collisions.cpp +++ b/common/geometry/shape_collisions.cpp @@ -310,6 +310,12 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed case SH_RECT: switch( aB->Type() ) { + case SH_RECT: // RECT to RECT not yet in use in p&s router + // Should be (todo) somethink like: + //return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); + assert( aB->Type() != SH_RECT ); + return true; + case SH_CIRCLE: return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index bb6e2216ca..85c1d5d20e 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -491,7 +491,8 @@ void DRC::testTracks( bool aShowProgressBar ) { progressDialog = new wxProgressDialog( _( "Track clearances" ), wxEmptyString, deltamax, m_mainWindow, - wxPD_AUTO_HIDE | wxPD_CAN_ABORT ); + wxPD_AUTO_HIDE | wxPD_CAN_ABORT | + wxPD_APP_MODAL | wxPD_ELAPSED_TIME ); progressDialog->Update( 0, wxEmptyString ); } diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 8c4cee21db..94e4c74df7 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -2115,10 +2115,12 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM() m_netCodes.resize( netCode+1 ); m_netCodes[netCode] = net->GetNet(); + net = NULL; } else { delete net; + net = NULL; // Avoid double deletion. } return; // preferred exit diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 401b0ea13f..e1c75b535b 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -283,7 +283,7 @@ static DRAWSEGMENT* findPoint( const wxPoint& aPoint, ::PCB_TYPE_COLLECTOR* item int ndx_min = 0; // find the point closest to aPoint and perhaps exactly matching aPoint. - for( int i = 0; iGetCount(); ++i ) + for( int i = 0; i < items->GetCount(); ++i ) { DRAWSEGMENT* graphic = (DRAWSEGMENT*) (*items)[i]; unsigned d; @@ -345,19 +345,24 @@ static DRAWSEGMENT* findPoint( const wxPoint& aPoint, ::PCB_TYPE_COLLECTOR* item } #if defined(DEBUG) - printf( "Unable to find segment matching point (%d,%d)\n", - aPoint.x, aPoint.y ); - - for( int i = 0; i< items->GetCount(); ++i ) + if( items->GetCount() ) { - DRAWSEGMENT* graphic = (DRAWSEGMENT*) (*items)[i]; + printf( "Unable to find segment matching point (%.6g,%.6g) (seg count %d)\n", + IU2um( aPoint.x )/1000, IU2um( aPoint.y )/1000, + items->GetCount()); - printf( "type=%s, GetStart()=%d,%d GetEnd()=%d,%d\n", - TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() ) ), - graphic->GetStart().x, - graphic->GetStart().y, - graphic->GetEnd().x, - graphic->GetEnd().y ); + for( int i = 0; i< items->GetCount(); ++i ) + { + DRAWSEGMENT* graphic = (DRAWSEGMENT*) (*items)[i]; + + printf( "item %d, type=%s, start=%.6g %.6g end=%.6g,%.6g\n", + i + 1, + TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() ) ), + IU2um( graphic->GetStart().x )/1000, + IU2um( graphic->GetStart().y )/1000, + IU2um( graphic->GetEnd().x )/1000, + IU2um( graphic->GetEnd().y )/1000 ); + } } #endif @@ -924,14 +929,9 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) for( int i = 0; iGetLayer() != Edge_Cuts ) - { items.Remove( i ); - } else // remove graphics not on Edge_Cuts layer - { - DBG( items[i]->Show( 0, std::cout );) ++i; - } } if( items.GetCount() ) diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index 023fb641d4..6b6415ac5e 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -135,10 +135,12 @@ int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow * aActiveWindow, bool aVerbose ) // Create a message with a long net name, and build a wxProgressDialog // with a correct size to show this long net name msg.Printf( FORMAT_STRING, 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) ); + if( aActiveWindow ) progressDialog = new wxProgressDialog( _( "Fill All Zones" ), msg, areaCount+2, aActiveWindow, - wxPD_AUTO_HIDE | wxPD_CAN_ABORT ); + wxPD_AUTO_HIDE | wxPD_CAN_ABORT | + wxPD_APP_MODAL | wxPD_ELAPSED_TIME ); // Display the actual message if( progressDialog ) progressDialog->Update( 0, _( "Starting zone fill..." ) );