Skip to content

VIA and ARC lock not reset when copying to clipboard

Description

When copying board items to the clipboard, the copied items are unlocked before being written, but the list of items unlocked is not exhaustive. As a result, VIA and ARC elements keep their (locked) flag when copied to the clipboard.

The offending code can be found in pcbnew/kicad_clipboard.cpp:202

       auto prepItem = [&]( BOARD_ITEM* titem ) {
                            // locked means "locked in place"; copied items therefore can't be locked
                            if( MODULE* module = dyn_cast<MODULE*>( titem ) )
                                module->SetLocked( false );
                            else if( TRACK* track = dyn_cast<TRACK*>( titem ) )
                                track->SetLocked( false );
                        };

The dyn_cast function will not return a valid pointer for subclasses of TRACK, so VIA and ARC are not handled here.

As a short term solution, they could be added, but it might also be an idea to unlock these as part of the copying process as that would be a bit more future-proof, such as when the option to lock zones is readded.

Steps to reproduce

  1. Create a new PCB
  2. Place a via and an arc
  3. Select both
  4. Copy to clipboard
  5. Look for (locked) in the clipboard contents

KiCad Version

Application: KiCad
Version: (5.99.0-6907-g61c8debb70), debug build
Libraries:
    wxWidgets 3.0.5
    libcurl/7.72.0 GnuTLS/3.6.15 zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.8.0 nghttp2/1.41.0 librtmp/2.3
Platform: Linux 5.9.0-1-amd64 x86_64, 64 bit, Little endian, wxGTK, , 
Build Info:
    Date: Nov 10 2020 17:47:56
    wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.71.0
    OCE: 6.9.1
    Curl: 7.72.0
    ngspice: 33
    Compiler: GCC 10.2.0 with C++ ABI 1014
Build settings:
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    KICAD_USE_OCE=ON
    KICAD_SPICE=ON
    KICAD_STDLIB_DEBUG=OFF
    KICAD_STDLIB_LIGHT_DEBUG=OFF
    KICAD_SANITIZE=OFF