You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

671 lines
22 KiB

1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2016 CERN
  7. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  8. * @author Maciej Suminski <maciej.suminski@cern.ch>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, you may find one here:
  22. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  23. * or you may search the http://www.gnu.org website for the version 2 license,
  24. * or you may write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  26. */
  27. #include <functional>
  28. using namespace std::placeholders;
  29. #include <macros.h>
  30. #include <pcb_edit_frame.h>
  31. #include <pcb_track.h>
  32. #include <pcb_group.h>
  33. #include <pcb_generator.h>
  34. #include <pcb_target.h>
  35. #include <footprint.h>
  36. #include <lset.h>
  37. #include <pad.h>
  38. #include <origin_viewitem.h>
  39. #include <connectivity/connectivity_data.h>
  40. #include <tool/tool_manager.h>
  41. #include <tool/actions.h>
  42. #include <tools/pcb_selection_tool.h>
  43. #include <tools/pcb_control.h>
  44. #include <tools/board_editor_control.h>
  45. #include <board_commit.h>
  46. #include <drawing_sheet/ds_proxy_undo_item.h>
  47. #include <wx/msgdlg.h>
  48. /* Functions to undo and redo edit commands.
  49. * commands to undo are stored in CurrentScreen->m_UndoList
  50. * commands to redo are stored in CurrentScreen->m_RedoList
  51. *
  52. * m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
  53. * Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
  54. * that store the list of schematic items that are concerned by the command to undo or redo
  55. * and is created for each command to undo (handle also a command to redo).
  56. * each picker has a pointer pointing to an item to undo or redo (in fact: deleted, added or
  57. * modified),
  58. * and has a pointer to a copy of this item, when this item has been modified
  59. * (the old values of parameters are therefore saved)
  60. *
  61. * there are 3 cases:
  62. * - delete item(s) command
  63. * - change item(s) command
  64. * - add item(s) command
  65. *
  66. * Undo command
  67. * - delete item(s) command:
  68. * => deleted items are moved in undo list
  69. *
  70. * - change item(s) command
  71. * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
  72. * the .m_Link member of each wrapper points the modified item.
  73. * the .m_Item member of each wrapper points the old copy of this item.
  74. *
  75. * - add item(s) command
  76. * =>A list of item(s) is made. The .m_Item member of each wrapper points the new item.
  77. *
  78. * Redo command
  79. * - delete item(s) old command:
  80. * => deleted items are moved in EEDrawList list, and in
  81. *
  82. * - change item(s) command
  83. * => the copy of item(s) is moved in Undo list
  84. *
  85. * - add item(s) command
  86. * => The list of item(s) is used to create a deleted list in undo list(same as a delete
  87. * command)
  88. *
  89. * Some block operations that change items can be undone without memorize items, just the
  90. * coordinates of the transform:
  91. * move list of items (undo/redo is made by moving with the opposite move vector)
  92. * mirror (Y) and flip list of items (undo/redo is made by mirror or flip items)
  93. * so they are handled specifically.
  94. *
  95. */
  96. void PCB_BASE_EDIT_FRAME::saveCopyInUndoList( PICKED_ITEMS_LIST* commandToUndo,
  97. const PICKED_ITEMS_LIST& aItemsList,
  98. UNDO_REDO aCommandType )
  99. {
  100. int preExisting = commandToUndo->GetCount();
  101. for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
  102. commandToUndo->PushItem( aItemsList.GetItemWrapper(ii) );
  103. for( unsigned ii = preExisting; ii < commandToUndo->GetCount(); ii++ )
  104. {
  105. EDA_ITEM* item = commandToUndo->GetPickedItem( ii );
  106. UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii );
  107. if( command == UNDO_REDO::UNSPECIFIED )
  108. {
  109. command = aCommandType;
  110. commandToUndo->SetPickedItemStatus( command, ii );
  111. }
  112. wxASSERT( item );
  113. switch( command )
  114. {
  115. case UNDO_REDO::CHANGED:
  116. case UNDO_REDO::DRILLORIGIN:
  117. case UNDO_REDO::GRIDORIGIN:
  118. // If we don't yet have a copy in the link, set one up
  119. if( !commandToUndo->GetPickedItemLink( ii ) )
  120. commandToUndo->SetPickedItemLink( BOARD_COMMIT::MakeImage( item ), ii );
  121. break;
  122. case UNDO_REDO::NEWITEM:
  123. case UNDO_REDO::DELETED:
  124. case UNDO_REDO::PAGESETTINGS:
  125. case UNDO_REDO::REGROUP:
  126. case UNDO_REDO::UNGROUP:
  127. break;
  128. default:
  129. wxFAIL_MSG( wxString::Format( wxT( "Unrecognized undo command: %X" ), command ) );
  130. break;
  131. }
  132. }
  133. if( commandToUndo->GetCount() )
  134. {
  135. /* Save the copy in undo list */
  136. PushCommandToUndoList( commandToUndo );
  137. /* Clear redo list, because after a new command one cannot redo a command */
  138. ClearUndoORRedoList( REDO_LIST );
  139. }
  140. else
  141. {
  142. // Should not occur
  143. wxASSERT( false );
  144. delete commandToUndo;
  145. }
  146. }
  147. void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aCommandType )
  148. {
  149. PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
  150. PICKED_ITEMS_LIST itemsList;
  151. itemsList.PushItem( ITEM_PICKER( nullptr, aItem, aCommandType ) );
  152. saveCopyInUndoList( commandToUndo, itemsList, aCommandType );
  153. }
  154. void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
  155. UNDO_REDO aCommandType )
  156. {
  157. PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
  158. commandToUndo->SetDescription( aItemsList.GetDescription() );
  159. saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
  160. }
  161. void PCB_BASE_EDIT_FRAME::AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList,
  162. UNDO_REDO aCommandType )
  163. {
  164. PICKED_ITEMS_LIST* commandToUndo = PopCommandFromUndoList();
  165. if( !commandToUndo )
  166. {
  167. commandToUndo = new PICKED_ITEMS_LIST();
  168. commandToUndo->SetDescription( aItemsList.GetDescription() );
  169. }
  170. saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
  171. }
  172. void PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent )
  173. {
  174. if( UndoRedoBlocked() )
  175. return;
  176. if( GetUndoCommandCount() <= 0 )
  177. return;
  178. // Inform tools that undo command was issued
  179. m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } );
  180. // Get the old list
  181. PICKED_ITEMS_LIST* list = PopCommandFromUndoList();
  182. // Undo the command
  183. PutDataInPreviousState( list );
  184. // Put the old list in RedoList
  185. list->ReversePickersListOrder();
  186. PushCommandToRedoList( list );
  187. OnModify();
  188. m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_POST, AS_GLOBAL } );
  189. m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
  190. GetCanvas()->Refresh();
  191. }
  192. void PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent )
  193. {
  194. if( UndoRedoBlocked() )
  195. return;
  196. if( GetRedoCommandCount() == 0 )
  197. return;
  198. // Inform tools that redo command was issued
  199. m_toolManager->ProcessEvent( EVENTS::UndoRedoPreEvent );
  200. // Get the old list
  201. PICKED_ITEMS_LIST* list = PopCommandFromRedoList();
  202. // Redo the command
  203. PutDataInPreviousState( list );
  204. // Put the old list in UndoList
  205. list->ReversePickersListOrder();
  206. PushCommandToUndoList( list );
  207. OnModify();
  208. m_toolManager->ProcessEvent( EVENTS::UndoRedoPostEvent );
  209. m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
  210. GetCanvas()->Refresh();
  211. }
  212. void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
  213. {
  214. bool not_found = false;
  215. bool reBuild_ratsnest = false;
  216. bool deep_reBuild_ratsnest = false; // true later if pointers must be rebuilt
  217. bool solder_mask_dirty = false;
  218. auto view = GetCanvas()->GetView();
  219. auto connectivity = GetBoard()->GetConnectivity();
  220. GetBoard()->IncrementTimeStamp(); // clear caches
  221. // Enum to track the modification type of items. Used to enable bulk BOARD_LISTENER
  222. // callbacks at the end of the undo / redo operation
  223. enum ITEM_CHANGE_TYPE
  224. {
  225. ADDED,
  226. DELETED,
  227. CHANGED
  228. };
  229. std::unordered_map<EDA_ITEM*, ITEM_CHANGE_TYPE> item_changes;
  230. auto update_item_change_state =
  231. [&]( EDA_ITEM* item, ITEM_CHANGE_TYPE change_type )
  232. {
  233. auto item_itr = item_changes.find( item );
  234. if( item_itr == item_changes.end() )
  235. {
  236. // First time we've seen this item - tag the current change type
  237. item_changes.insert( { item, change_type } );
  238. return;
  239. }
  240. // Update the item state based on the current and next change type
  241. switch( item_itr->second )
  242. {
  243. case ITEM_CHANGE_TYPE::ADDED:
  244. {
  245. if( change_type == ITEM_CHANGE_TYPE::DELETED )
  246. {
  247. // The item was previously added, now deleted - as far as bulk callbacks
  248. // are concerned, the item has never existed
  249. item_changes.erase( item_itr );
  250. }
  251. else if( change_type == ITEM_CHANGE_TYPE::ADDED )
  252. {
  253. // Error condition - added an already added item
  254. wxASSERT_MSG( false, wxT( "UndoRedo: should not add already added item" ) );
  255. }
  256. // For all other cases, the item remains as ADDED as seen by the bulk callbacks
  257. break;
  258. }
  259. case ITEM_CHANGE_TYPE::DELETED:
  260. {
  261. // This is an error condition - item has already been deleted so should not
  262. // be operated on further
  263. wxASSERT_MSG( false, wxT( "UndoRedo: should not alter already deleted item" ) );
  264. break;
  265. }
  266. case ITEM_CHANGE_TYPE::CHANGED:
  267. {
  268. if( change_type == ITEM_CHANGE_TYPE::DELETED )
  269. {
  270. item_itr->second = ITEM_CHANGE_TYPE::DELETED;
  271. }
  272. else if( change_type == ITEM_CHANGE_TYPE::ADDED )
  273. {
  274. // This is an error condition - item has already been changed so should not
  275. // be added
  276. wxASSERT_MSG( false,
  277. wxT( "UndoRedo: should not add already changed item" ) );
  278. }
  279. // Otherwise, item remains CHANGED
  280. break;
  281. }
  282. }
  283. };
  284. // Undo in the reverse order of list creation: (this can allow stacked changes
  285. // like the same item can be changes and deleted in the same complex command
  286. // Restore changes in reverse order
  287. for( int ii = (int) aList->GetCount() - 1; ii >= 0 ; ii-- )
  288. {
  289. EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii );
  290. /* Test for existence of item on board.
  291. * It could be deleted, and no more on board:
  292. * - if a call to SaveCopyInUndoList was forgotten in Pcbnew
  293. * - in zones outlines, when a change in one zone merges this zone with an other
  294. * This test avoids a Pcbnew crash
  295. * Obviously, this test is not made for deleted items
  296. */
  297. UNDO_REDO status = aList->GetPickedItemStatus( ii );
  298. if( status != UNDO_REDO::DELETED
  299. && status != UNDO_REDO::REGROUP
  300. && status != UNDO_REDO::UNGROUP
  301. && status != UNDO_REDO::DRILLORIGIN // origin markers never on board
  302. && status != UNDO_REDO::GRIDORIGIN // origin markers never on board
  303. && status != UNDO_REDO::PAGESETTINGS ) // nor are page settings proxy items
  304. {
  305. if( GetBoard()->GetItem( eda_item->m_Uuid ) == DELETED_BOARD_ITEM::GetInstance() )
  306. {
  307. // Checking if it ever happens
  308. wxASSERT_MSG( false, wxT( "Item in the undo buffer does not exist" ) );
  309. // Remove this non existent item
  310. aList->RemovePicker( ii );
  311. not_found = true;
  312. if( aList->GetCount() == 0 )
  313. break;
  314. continue;
  315. }
  316. }
  317. // see if we must rebuild ratsnets and pointers lists
  318. switch( eda_item->Type() )
  319. {
  320. case PCB_FOOTPRINT_T:
  321. deep_reBuild_ratsnest = true; // Pointers on pads can be invalid
  322. KI_FALLTHROUGH;
  323. case PCB_ZONE_T:
  324. case PCB_TRACE_T:
  325. case PCB_ARC_T:
  326. case PCB_VIA_T:
  327. case PCB_PAD_T:
  328. reBuild_ratsnest = true;
  329. break;
  330. case PCB_NETINFO_T:
  331. reBuild_ratsnest = true;
  332. deep_reBuild_ratsnest = true;
  333. break;
  334. default:
  335. break;
  336. }
  337. switch( eda_item->Type() )
  338. {
  339. case PCB_FOOTPRINT_T:
  340. solder_mask_dirty = true;
  341. break;
  342. case PCB_VIA_T:
  343. solder_mask_dirty = true;
  344. break;
  345. case PCB_ZONE_T:
  346. case PCB_TRACE_T:
  347. case PCB_ARC_T:
  348. case PCB_PAD_T:
  349. case PCB_SHAPE_T:
  350. {
  351. LSET layers = static_cast<BOARD_ITEM*>( eda_item )->GetLayerSet();
  352. if( layers.test( F_Mask ) || layers.test( B_Mask ) )
  353. solder_mask_dirty = true;
  354. break;
  355. }
  356. default:
  357. break;
  358. }
  359. switch( aList->GetPickedItemStatus( ii ) )
  360. {
  361. case UNDO_REDO::CHANGED: /* Exchange old and new data for each item */
  362. {
  363. BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
  364. BOARD_ITEM_CONTAINER* parent = GetBoard();
  365. PCB_GROUP* parentGroup = item->GetParentGroup();
  366. if( item->GetParentFootprint() )
  367. {
  368. // We need the current item and it's parent, which may be different from what
  369. // was stored if we're multiple frames up the undo stack.
  370. item = GetBoard()->GetItem( item->m_Uuid );
  371. parent = item->GetParentFootprint();
  372. }
  373. BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
  374. view->Remove( item );
  375. if( parentGroup )
  376. parentGroup->RemoveItem( item );
  377. parent->Remove( item );
  378. item->SwapItemData( image );
  379. item->ClearFlags( UR_TRANSIENT );
  380. image->SetFlags( UR_TRANSIENT );
  381. if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( item ) )
  382. {
  383. group->RunOnChildren( [&]( BOARD_ITEM* child )
  384. {
  385. child->SetParentGroup( group );
  386. } );
  387. }
  388. view->Add( item );
  389. view->Hide( item, false );
  390. parent->Add( item );
  391. if( parentGroup )
  392. parentGroup->AddItem( item );
  393. update_item_change_state( item, ITEM_CHANGE_TYPE::CHANGED );
  394. break;
  395. }
  396. case UNDO_REDO::NEWITEM: /* new items are deleted */
  397. aList->SetPickedItemStatus( UNDO_REDO::DELETED, ii );
  398. GetModel()->Remove( (BOARD_ITEM*) eda_item, REMOVE_MODE::BULK );
  399. update_item_change_state( eda_item, ITEM_CHANGE_TYPE::DELETED );
  400. if( eda_item->Type() != PCB_NETINFO_T )
  401. view->Remove( eda_item );
  402. eda_item->SetFlags( UR_TRANSIENT );
  403. break;
  404. case UNDO_REDO::DELETED: /* deleted items are put in List, as new items */
  405. aList->SetPickedItemStatus( UNDO_REDO::NEWITEM, ii );
  406. eda_item->ClearFlags( UR_TRANSIENT );
  407. GetModel()->Add( (BOARD_ITEM*) eda_item, ADD_MODE::BULK_APPEND );
  408. update_item_change_state( eda_item, ITEM_CHANGE_TYPE::ADDED );
  409. if( eda_item->Type() != PCB_NETINFO_T )
  410. view->Add( eda_item );
  411. break;
  412. case UNDO_REDO::REGROUP: /* grouped items are ungrouped */
  413. aList->SetPickedItemStatus( UNDO_REDO::UNGROUP, ii );
  414. if( eda_item->IsBOARD_ITEM() )
  415. {
  416. BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( eda_item );
  417. if( PCB_GROUP* group = boardItem->GetParentGroup() )
  418. {
  419. aList->SetPickedItemGroupId( group->m_Uuid, ii );
  420. group->RemoveItem( boardItem );
  421. }
  422. }
  423. break;
  424. case UNDO_REDO::UNGROUP: /* ungrouped items are re-added to their previuos groups */
  425. aList->SetPickedItemStatus( UNDO_REDO::REGROUP, ii );
  426. if( eda_item->IsBOARD_ITEM() )
  427. {
  428. BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( eda_item );
  429. PCB_GROUP* group = dynamic_cast<PCB_GROUP*>(
  430. GetBoard()->GetItem( aList->GetPickedItemGroupId( ii ) ) );
  431. if( group )
  432. group->AddItem( boardItem );
  433. }
  434. break;
  435. case UNDO_REDO::DRILLORIGIN:
  436. case UNDO_REDO::GRIDORIGIN:
  437. {
  438. // Warning: DRILLORIGIN and GRIDORIGIN undo/redo command create EDA_ITEMs
  439. // that cannot be casted to BOARD_ITEMs
  440. EDA_ITEM* image = aList->GetPickedItemLink( ii );
  441. VECTOR2D origin = image->GetPosition();
  442. image->SetPosition( eda_item->GetPosition() );
  443. if( aList->GetPickedItemStatus( ii ) == UNDO_REDO::DRILLORIGIN )
  444. BOARD_EDITOR_CONTROL::DoSetDrillOrigin( view, this, eda_item, origin );
  445. else
  446. PCB_CONTROL::DoSetGridOrigin( view, this, eda_item, origin );
  447. break;
  448. }
  449. case UNDO_REDO::PAGESETTINGS:
  450. {
  451. // swap current settings with stored settings
  452. DS_PROXY_UNDO_ITEM alt_item( this );
  453. DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
  454. item->Restore( this );
  455. *item = std::move( alt_item );
  456. break;
  457. }
  458. default:
  459. wxFAIL_MSG( wxString::Format( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
  460. aList->GetPickedItemStatus( ii ) ) );
  461. break;
  462. }
  463. }
  464. if( not_found )
  465. wxMessageBox( _( "Incomplete undo/redo operation: some items not found" ) );
  466. if( IsType( FRAME_PCB_EDITOR ) )
  467. {
  468. if( reBuild_ratsnest || deep_reBuild_ratsnest )
  469. {
  470. // Connectivity may have changed; rebuild internal caches to remove stale items
  471. GetBoard()->BuildConnectivity();
  472. Compile_Ratsnest( false );
  473. }
  474. if( solder_mask_dirty )
  475. HideSolderMask();
  476. }
  477. PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
  478. selTool->RebuildSelection();
  479. GetBoard()->SanitizeNetcodes();
  480. // Invoke bulk BOARD_LISTENER callbacks
  481. std::vector<BOARD_ITEM*> added_items, deleted_items, changed_items;
  482. for( auto& [item, changeType] : item_changes )
  483. {
  484. switch( changeType )
  485. {
  486. case ITEM_CHANGE_TYPE::ADDED:
  487. added_items.push_back( static_cast<BOARD_ITEM*>( item ) );
  488. break;
  489. case ITEM_CHANGE_TYPE::DELETED:
  490. deleted_items.push_back( static_cast<BOARD_ITEM*>( item ) );
  491. break;
  492. case ITEM_CHANGE_TYPE::CHANGED:
  493. changed_items.push_back( static_cast<BOARD_ITEM*>( item ) );
  494. break;
  495. }
  496. }
  497. if( added_items.size() > 0 || deleted_items.size() > 0 || changed_items.size() > 0 )
  498. GetBoard()->OnItemsCompositeUpdate( added_items, deleted_items, changed_items );
  499. }
  500. void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
  501. {
  502. if( aItemCount == 0 )
  503. return;
  504. UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
  505. if( aItemCount < 0 )
  506. {
  507. list.ClearCommandList();
  508. }
  509. else
  510. {
  511. for( int ii = 0; ii < aItemCount; ii++ )
  512. {
  513. if( list.m_CommandsList.size() == 0 )
  514. break;
  515. PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
  516. list.m_CommandsList.erase( list.m_CommandsList.begin() );
  517. ClearListAndDeleteItems( curr_cmd );
  518. delete curr_cmd; // Delete command
  519. }
  520. }
  521. }
  522. void PCB_BASE_EDIT_FRAME::ClearListAndDeleteItems( PICKED_ITEMS_LIST* aList )
  523. {
  524. aList->ClearListAndDeleteItems(
  525. []( EDA_ITEM* item )
  526. {
  527. wxASSERT_MSG( item->HasFlag( UR_TRANSIENT ),
  528. "Item on undo/redo list not owned by undo/redo!" );
  529. if( item->IsBOARD_ITEM() )
  530. static_cast<BOARD_ITEM*>( item )->SetParentGroup( nullptr );
  531. delete item;
  532. } );
  533. }
  534. void PCB_BASE_EDIT_FRAME::RollbackFromUndo()
  535. {
  536. PICKED_ITEMS_LIST* undo = PopCommandFromUndoList();
  537. PutDataInPreviousState( undo );
  538. ClearListAndDeleteItems( undo );
  539. delete undo;
  540. GetCanvas()->Refresh();
  541. }