Commit 304525db authored by charras's avatar charras
Browse files

undo/redo rework: fixed some problems ans crashes (not all) in libedit and modedit

parent 8d5a6531
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -219,7 +219,6 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
    maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START;
    maxZoomIds = ( (size_t) maxZoomIds < GetScreen()->m_ZoomList.GetCount() ) ?
        maxZoomIds : GetScreen()->m_ZoomList.GetCount();
    wxLogDebug( _T( "%d zoom IDs used." ), maxZoomIds );

    /* Populate zoom submenu. */
    for( i = 0; i < (size_t) maxZoomIds; i++ )
+13 −0
Original line number Diff line number Diff line
@@ -229,6 +229,19 @@ public:
                        {
                        }

    /** Function SaveCopyInUndoList (overloaded).
     * Creates a new entry in undo list of commands.
     * add a list of pickers to handle a list of items
     * @param aItemsList = the list of items modified by the command to undo
     * @param aTypeCommand = command type (see enum UndoRedoOpType)
     * @param aTransformPoint = the reference point of the transformation, for commands like move
     */
    virtual void    SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
                        const wxPoint& aTransformPoint = wxPoint(0,0) )
    {
        // currently: do nothing in cvpcb.
    }

    DECLARE_EVENT_TABLE()
};

+4 −14
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
    CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy );

    lastcmd = new PICKED_ITEMS_LIST();
    ITEM_PICKER wrapper(CopyItem);
    ITEM_PICKER wrapper(CopyItem, UR_LIBEDIT);
    lastcmd->PushItem(wrapper);
    GetScreen()->PushCommandToUndoList( lastcmd );
    /* Clear current flags (which can be temporary set by a current edit command) */
@@ -34,17 +34,7 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
        item->m_Flags = 0;

    /* Clear redo list, because after new save there is no redo to do */
    while( (lastcmd = GetScreen()->PopCommandFromRedoList( ) ) != NULL )
    {
        while ( 1 )
        {
            wrapper = lastcmd->PopItem();
            if ( wrapper.m_PickedItem == NULL )
                break;      // All items are removed
            delete wrapper.m_PickedItem;
        }
        delete lastcmd;
    }
    GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
}


@@ -62,7 +52,7 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
        return;

    PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
    ITEM_PICKER wrapper(CurrentLibEntry);
    ITEM_PICKER wrapper(CurrentLibEntry, UR_LIBEDIT);
    lastcmd->PushItem(wrapper);
    GetScreen()->PushCommandToUndoList( lastcmd );

@@ -95,7 +85,7 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
        return;

    PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
    ITEM_PICKER wrapper(CurrentLibEntry);
    ITEM_PICKER wrapper(CurrentLibEntry, UR_LIBEDIT);
    lastcmd->PushItem(wrapper);
    GetScreen()->PushCommandToRedoList( lastcmd );

+4 −0
Original line number Diff line number Diff line
@@ -509,6 +509,10 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
            case UR_NEW:        // Do nothing, items are in use
                break;

            case UR_LIBEDIT:    // Libedit save always a copy of the current item
                delete item;    // So, the picker is always owner of the picked item
                break;

            case UR_DELETED:
                delete item;    // Delete the picked item, because it was deleted from schematic
                break;
+12 −0
Original line number Diff line number Diff line
@@ -175,6 +175,18 @@ public:
                        const wxPoint& aTransformPoint = wxPoint(0,0) )
                        {
                        }
    /** Function SaveCopyInUndoList (overloaded).
     * Creates a new entry in undo list of commands.
     * add a list of pickers to handle a list of items
     * @param aItemsList = the list of items modified by the command to undo
     * @param aTypeCommand = command type (see enum UndoRedoOpType)
     * @param aTransformPoint = the reference point of the transformation, for commands like move
     */
    virtual void    SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
                        const wxPoint& aTransformPoint = wxPoint(0,0) )
    {
        // currently: do nothing in gerbview.
    }


    DECLARE_EVENT_TABLE()
Loading