Broken input validation in Spice Model Editor

Bug #1743486 reported by PyroPeter
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Low
Unassigned

Bug Description

Steps to reproduce:
1. Open eeschema
2. Create pspice:VSOURCE
3. Edit properties
4. Edit spice model
5. In 'Transient analysis', 'Pulse' (or any other register card), leave the first field empty, but put text in the second field.
6. Click OK

Expected behaviour:
Error message: "You need to specify at least the first 2 parameters for the transient source"

Buggy behaviour:
Dialog closes without complaints, but does not save the settings.

Cause:
In eeschema/dialogs/dialog_spice_model.cpp around line 551, there is the following if-statement:

if( paramCounter == 0 )
{
    // It is fine, no parameters were entered
    useTrans = false;
    break;
}

This makes the false assumption that, if the first field is empty, all the other fields must be empty, too. (Probably assumes the user knows what they are doing. But I don't!)

Application: kicad
Version: (2018-01-15 revision 94c8a947a)-makepkg, release build
Libraries:
    wxWidgets 3.0.3
    libcurl/7.57.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.18.0 (+libidn2/2.0.4) libssh2/1.8.0 nghttp2/1.27.0
Platform: Linux 4.14.3-1-ARCH x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
    Boost: 1.65.1
    Curl: 7.57.0
    Compiler: GCC 7.2.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=OFF
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_SPICE=ON

tags: added: ngspice
tags: added: eeschema
Changed in kicad:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Dan Weatherill (dan-weatherill) wrote :

I think the problem is, that it is perfectly valid to not fill in any values for transient analysis on a source, if it is being used as a DC source.

Revision history for this message
Dan Weatherill (dan-weatherill) wrote :

Hi PyroPeter,
I see my previous comment wasn't correct. Can you try this patch and see if it fixes the issue for you ?

THanks,
Dan W

Revision history for this message
Dan Weatherill (dan-weatherill) wrote :

updated patch which also removes the (now unused) variables. Apologies for the noise

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision 590cac9d5565985a9bb299ad94bc130fb5ee8488
https://git.launchpad.net/kicad/patch/?id=590cac9d5565985a9bb299ad94bc130fb5ee8488

Changed in kicad:
status: Confirmed → Fix Committed
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Thank you Dan, I applied your patch and some extra fixes on top of it.

Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.