Commit c63908b5 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew, Module Editor: fix bug 707692 and other potential crashes (when having...

Pcbnew, Module Editor: fix bug 707692 and other potential crashes (when having a block command in progress and try to make an edit command)
parent 4f3708c1
......@@ -6,7 +6,7 @@
#endif
#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-01-25 BZR 2758)"
#define KICAD_BUILD_VERSION "(2011-01-26 BZR 2759)"
#endif
//#define VERSION_STABILITY "stable"
......
......@@ -17,7 +17,7 @@
; General Product Description Definitions
!define PRODUCT_NAME "KiCad"
!define PRODUCT_VERSION "2011.01.25"
!define PRODUCT_VERSION "2011.01.26"
!define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/"
!define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/"
!define COMPANY_NAME ""
......
......@@ -22,16 +22,16 @@
/*****************************************************************************************/
void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_ITEM* DrawStruct )
{
/*****************************************************************************************/
/* Hot keys. Some commands are relative to the item under the mouse cursor
* Commands are case insensitive
*/
{
if( hotkey == 0 )
return;
BOARD_ITEM* item = GetCurItem();
bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE;
BOARD_ITEM* item = GetCurItem();
bool ItemFree = (item == 0) || (item->m_Flags == 0);
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
......@@ -60,7 +60,8 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_ITEM* DrawStru
break;
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
if( !blockActive )
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
break;
case HK_SWITCH_UNITS:
......@@ -89,7 +90,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_ITEM* DrawStru
case HK_UNDO:
case HK_REDO:
if( ItemFree )
if( ItemFree && !blockActive )
{
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
HK_Descr->m_IdMenuEvent );
......@@ -120,12 +121,14 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_ITEM* DrawStru
}
}
bool WinEDA_ModuleEditFrame::OnHotkeyEditItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
bool itemCurrentlyEdited = item && item->m_Flags;
bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE;
if( itemCurrentlyEdited )
if( itemCurrentlyEdited || blockActive )
return false;
item = ModeditLocateAndDisplay();
......@@ -170,12 +173,14 @@ bool WinEDA_ModuleEditFrame::OnHotkeyEditItem( int aIdCommand )
return false;
}
bool WinEDA_ModuleEditFrame::OnHotkeyDeleteItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
bool itemCurrentlyEdited = item && item->m_Flags;
bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE;
if( itemCurrentlyEdited )
if( itemCurrentlyEdited || blockActive )
return false;
item = ModeditLocateAndDisplay();
......@@ -220,12 +225,14 @@ bool WinEDA_ModuleEditFrame::OnHotkeyDeleteItem( int aIdCommand )
return false;
}
bool WinEDA_ModuleEditFrame::OnHotkeyMoveItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
bool itemCurrentlyEdited = item && item->m_Flags;
bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE;
if( itemCurrentlyEdited )
if( itemCurrentlyEdited || blockActive )
return false;
item = ModeditLocateAndDisplay();
......@@ -270,11 +277,16 @@ bool WinEDA_ModuleEditFrame::OnHotkeyMoveItem( int aIdCommand )
return false;
}
bool WinEDA_ModuleEditFrame::OnHotkeyRotateItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
int evt_type = 0; // Used to post a wxCommandEvent on demand
int evt_type = 0; // Used to post a wxCommandEvent on demand
bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE;
if( blockActive )
return false;
if( !itemCurrentlyEdited )
item = ModeditLocateAndDisplay();
......
......@@ -23,26 +23,26 @@
*/
void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
BOARD_ITEM* DrawStruct = GetCurItem();
BOARD_ITEM* item = GetCurItem();
DrawPanel->CursorOff( DC );
if( m_ID_current_state == 0 )
{
if( DrawStruct && DrawStruct->m_Flags ) // Command in progress
if( item && item->m_Flags ) // Command in progress
{
switch( DrawStruct->Type() )
switch( item->Type() )
{
case TYPE_TEXTE_MODULE:
PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC );
PlaceTexteModule( (TEXTE_MODULE*) item, DC );
break;
case TYPE_EDGE_MODULE:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Place_EdgeMod( (EDGE_MODULE*) DrawStruct );
Place_EdgeMod( (EDGE_MODULE*) item );
break;
case TYPE_PAD:
PlacePad( (D_PAD*) DrawStruct, DC );
PlacePad( (D_PAD*) item, DC );
break;
default:
......@@ -50,23 +50,22 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
wxString msg;
msg.Printf( wxT( "WinEDA_ModEditFrame::OnLeftClick err: \
m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
DrawStruct, DrawStruct->Type(),
DrawStruct->m_Flags );
item, item->Type(), item->m_Flags );
DisplayError( this, msg );
DrawStruct->m_Flags = 0;
item->m_Flags = 0;
break;
}
}
}
}
DrawStruct = GetCurItem();
if( !DrawStruct || (DrawStruct->m_Flags == 0) )
item = GetCurItem();
if( !item || (item->m_Flags == 0) )
{
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
&& !wxGetKeyState( WXK_CONTROL ) )
DrawStruct = ModeditLocateAndDisplay();
SetCurItem( DrawStruct );
item = ModeditLocateAndDisplay();
SetCurItem( item );
}
switch( m_ID_current_state )
......@@ -80,7 +79,7 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
case ID_PCB_CIRCLE_BUTT:
case ID_PCB_ARC_BUTT:
case ID_PCB_ADD_LINE_BUTT:
if( !DrawStruct || DrawStruct->m_Flags == 0 )
if( !item || item->m_Flags == 0 )
{
int shape = S_SEGMENT;
if( m_ID_current_state == ID_PCB_CIRCLE_BUTT )
......@@ -91,39 +90,39 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
SetCurItem(
Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
}
else if( (DrawStruct->m_Flags & IS_NEW) )
else if( (item->m_Flags & IS_NEW) )
{
if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_CIRCLE )
if( ( (EDGE_MODULE*) item )->m_Shape == S_CIRCLE )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct );
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
DrawPanel->Refresh();
}
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_ARC )
else if( ( (EDGE_MODULE*) item )->m_Shape == S_ARC )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct );
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
DrawPanel->Refresh();
}
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_SEGMENT )
else if( ( (EDGE_MODULE*) item )->m_Shape == S_SEGMENT )
{
SetCurItem(
Begin_Edge_Module( (EDGE_MODULE*) DrawStruct, DC, 0 ) );
Begin_Edge_Module( (EDGE_MODULE*) item, DC, 0 ) );
}
else
DisplayError( this,
wxT( "ProcessCommand error: DrawStruct flags error" ) );
wxT( "ProcessCommand error: item flags error" ) );
}
break;
case ID_MODEDIT_DELETE_ITEM_BUTT:
if( DrawStruct == NULL || // No item to delete
(DrawStruct->m_Flags != 0) ) // Item in edit, cannot delete it
if( item == NULL || // No item to delete
(item->m_Flags != 0) ) // Item in edit, cannot delete it
break;
if( DrawStruct->Type() != TYPE_MODULE ) // Cannot delete the module itself
if( item->Type() != TYPE_MODULE ) // Cannot delete the module itself
{
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
RemoveStruct( DrawStruct );
RemoveStruct( item );
SetCurItem( NULL );
}
break;
......@@ -190,22 +189,21 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu )
{
BOARD_ITEM* DrawStruct = GetCurItem();
BOARD_ITEM* item = GetCurItem();
wxString msg;
bool append_set_width = FALSE;
bool BlockActive =
( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE );
bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE;
// Simple location of elements where possible.
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{
SetCurItem( DrawStruct = ModeditLocateAndDisplay() );
SetCurItem( item = ModeditLocateAndDisplay() );
}
// End command in progress.
if( m_ID_current_state )
{
if( DrawStruct && DrawStruct->m_Flags )
if( item && item->m_Flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), cancel_xpm );
......@@ -217,9 +215,9 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
}
else
{
if( (DrawStruct && DrawStruct->m_Flags) || BlockActive )
if( (item && item->m_Flags) || blockActive )
{
if( BlockActive ) // Put block commands in list
if( blockActive ) // Put block commands in list
{
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel Block" ), cancel_xpm );
......@@ -251,12 +249,12 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
}
}
if( DrawStruct == NULL )
if( (item == NULL) || blockActive )
return true;
int flags = DrawStruct->m_Flags;
int flags = item->m_Flags;
switch( DrawStruct->Type() )
switch( item->Type() )
{
case TYPE_MODULE:
{
......@@ -321,7 +319,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
HK_EDIT_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE,
msg, edit_text_xpm );
if( ( (TEXTE_MODULE*) DrawStruct )->m_Type == TEXT_is_DIVERS )
if( ( (TEXTE_MODULE*) item )->m_Type == TEXT_is_DIVERS )
{
msg = AddHotkeyName( _("Delete Text Mod." ), g_Module_Editor_Hokeys_Descr,
HK_DELETE );
......@@ -380,13 +378,13 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
case TYPE_NOT_INIT:
case TYPE_PCB:
msg.Printf( wxT( "WinEDA_ModuleEditFrame::OnRightClick Error: illegal DrawType %d" ),
DrawStruct->Type() );
item->Type() );
DisplayError( this, msg );
break;
default:
msg.Printf( wxT( "WinEDA_ModuleEditFrame::OnRightClick Error: unknown DrawType %d" ),
DrawStruct->Type() );
item->Type() );
DisplayError( this, msg );
break;
}
......@@ -413,33 +411,33 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
*/
void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{
BOARD_ITEM* DrawStruct = GetCurItem();
BOARD_ITEM* item = GetCurItem();
wxPoint pos = GetPosition();
switch( m_ID_current_state )
{
case 0:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{
DrawStruct = ModeditLocateAndDisplay();
item = ModeditLocateAndDisplay();
}
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags != 0 ) )
if( ( item == NULL ) || ( item->m_Flags != 0 ) )
break;
// Item found
SetCurItem( DrawStruct );
SetCurItem( item );
switch( DrawStruct->Type() )
switch( item->Type() )
{
case TYPE_PAD:
InstallPadOptionsFrame( (D_PAD*) DrawStruct );
InstallPadOptionsFrame( (D_PAD*) item );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_MODULE:
{
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) DrawStruct );
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) item );
int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0;
DrawPanel->MouseToCursorSchema();
......@@ -449,7 +447,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break;
case TYPE_TEXTE_MODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, DC );
InstallTextModOptionsFrame( (TEXTE_MODULE*) item, DC );
DrawPanel->MouseToCursorSchema();
break;
......@@ -461,9 +459,9 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case ID_PCB_ADD_LINE_BUTT:
{
if( DrawStruct && ( DrawStruct->m_Flags & IS_NEW ) )
if( item && ( item->m_Flags & IS_NEW ) )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct );
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
DrawPanel->Refresh();
}
......
......@@ -30,7 +30,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
wxString msg;
int flags = 0;
bool locate_track = FALSE;
bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
bool blockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
wxClientDC dc( DrawPanel );
......@@ -42,7 +42,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
// If a command or a block is in progress:
// Put the Cancel command (if needed) and the End command
if( BlockActive )
if( blockActive )
{
createPopUpBlockMenu( aPopMenu );
aPopMenu->AppendSeparator();
......
release version:
2011 jan 25
2011 jan 26
files (.zip,.tgz):
kicad-2011-01-25
kicad-2011-01-26
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment