← Back to team overview

kicad-developers team mailing list archive

Re: [Patch] pcbnew clipboard support

 

On 24.09.2017 19:44, Kristoffer Ödmark wrote:
> I just pushed a larger change for this patch. Before the items was
> always added to the board on paste, even if the user aborted the action.
> This resulted in duplicate items stuck on the board since they were
> pasted directly to the same position, making it easy to miss and would
> be tedious to clean up at a later time.
> 
> Now, when pasting and pressing escape to abort. The items pasted will
> not be added to the board. This is a rewrite of the appendBoard stuff
> with a few changes.
> 
> Please try to crash it.
> 
> The code is available for testing at:
> 
> https://code.launchpad.net/~kristoffer-odmark/kicad/+git/kicad/+ref/copypasta
> 
> 
Hi Kristoffer,

I've had some time to work on your code during the past few days (I
wasn't aware you're still improving it). I fixed the crashes, refactored
placement of pasted items, fixed the zone refill issue, added snapping
to item's anchors and selection of a reference point.

The only outstanding bug I'm aware of is with net code propagation (not
updated after pasting items).

How do you want to proceed with this? I'd like to merge the copy&paste
feature as soon as possible.

Best,
Tom


> 
> On 09/19/2017 01:12 AM, Kristoffer Ödmark wrote:
>> Thank you Tomasz!
>>
>> That was most likely the error, I cannot reproduce the crash after
>> fixing so that I do not modify the existing board!
>>
>> I updated the branch, now bed for me!
>>
>> - Kristofffer
>>
>> On 09/18/2017 11:54 PM, Tomasz Wlostowski wrote:
>>> On 18.09.2017 22:37, Kristoffer Ödmark wrote:
>>>> I have made almost no changes as of yet. Just trying to figure out what
>>>> causes the crash.
>>>
>>> Hi,
>>>
>>> Looking at kicad_clipboard.cpp:
>>>
>>> // only a module selected.
>>>      if( aSelected.Size() == 1 && aSelected.Front()->Type() ==
>>> PCB_MODULE_T )
>>>      {
>>>          // make the module safe to transfer to other pcbs
>>>          MODULE* mod = static_cast<MODULE*>( aSelected.Front() );
>>>          for( D_PAD* pad = mod->PadsList().begin(); pad; pad =
>>> pad->Next() )
>>>          {
>>>              pad->SetNetCode( 0,0 );
>>>          }
>>>
>>>          Format(static_cast<BOARD_ITEM*>( mod ) );
>>>      }
>>>
>>> Why are you modifying the net codes of the items owned by the BOARD
>>> class here? Shouldn't this be performed on a copy that to be formatted
>>> for the clipboard? I noticed you're creating a stack MODULE object a few
>>> lines up, but you're not using it in this particular case, could this be
>>> the problem?
>>>
>>> Tom
>>>
>>>
>>>
>>>>
>>>> I noticed in pcbnew/tools/edit_tool.cpp cutToClipboard that the method
>>>> does not cause a crash If i only run on of the two method calls in it.
>>>> Doesnt matter which one I remove, I also noticed that the crash is due
>>>> to a CN_ANCHOR not being valid.
>>>>
>>>> #4  0x00007fffe5cd1ab3 in CN_ANCHOR::Parent (this=0x5555588178a0) at
>>>> /home/krille/projects/kicad/pcbnew/connectivity_algo.cpp:924
>>>> 924        assert( m_item->Valid() );
>>>> (gdb) p *m_item
>>>> $1 = {<INTRUSIVE_LIST<CN_ITEM>> = {m_count = 1484021408, m_prev =
>>>> 0x670000006e, m_next = 0x2200000020, m_root = 0x6c00000025},
>>>> _vptr.CN_ITEM = 0x55555753f9c0, m_parent = 0x2200000073, m_connected =
>>>> std::vector of length -40802189302, capacity 1610612745 = {<error
>>>> reading variable>
>>>>
>>>>
>>>> On 09/18/2017 09:44 PM, Tomasz Wlostowski wrote:
>>>>> On 18.09.2017 21:18, Kristoffer Ödmark wrote:
>>>>>> I cannot reproduce the crash on copying, I can however crash it on
>>>>>> the
>>>>>> Cut functionality, I am at a total loss as to why though.
>>>>>>
>>>>>> I noticed that the crash does not happen if one hides the board
>>>>>> ratsnest, but it will later crash when trying to re-enable the
>>>>>> ratsnest.
>>>>>>
>>>>>> Can someone maybe help shed some light on this?
>>>>> Push the latest code, if it's ratsnest-related, I might have a look.
>>>>>
>>>>> Tom
>>>>>>
>>>>>> On 09/18/2017 01:35 PM, Tomasz Wlostowski wrote:
>>>>>>> On 18.09.2017 12:57, Kristoffer Ödmark wrote:
>>>>>>>> Hmm, I cannot manage to reproduce the crash.
>>>>>>>>
>>>>>>>> The things you are testing on, is the components pasted in using an
>>>>>>>> earlier version?
>>>>>>>>
>>>>>>> Hi Kristoffer,
>>>>>>>
>>>>>>> Open the attached board, select P19 (connector on the right side)
>>>>>>> and
>>>>>>> press Ctrl-C. A segfault will occur (at least on my machine) -
>>>>>>> release
>>>>>>> x86_64 build.
>>>>>>>
>>>>>>> PS. Why all the zones are refilled after pasting something? Is this
>>>>>>> intentional?
>>>>>>>
>>>>>>> Tom
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>



Follow ups

References