bloguetronica / cp2130-conf

CP2130 Configurator (cp2130-conf) is an application that can be used to configure CP2130 devices, including VID, PID, as well as other descriptors. Most importantly, the application allows you to configure pin functions and states.
GNU General Public License v3.0
1 stars 1 forks source link

Zero-length serial numbers must not be accepted as valid #44

Open samuelfmlourenco opened 2 weeks ago

samuelfmlourenco commented 2 weeks ago

The application currently allows a zero-length serial number to be written. However, that invalidates the CP2130 device, making it unusable. Therefore, the application must check if the "Serial number" line edit box is not empty before writing the configuration to the device.

samuelfmlourenco commented 2 weeks ago

To fix this issue, two changes will have to be made to "configuratorwindow.cpp" and "configuratorwindow.h", including a new function:

void ConfiguratorWindow::on_lineEditSerial_textChanged()
{
    if (ui->lineEditSerial->text().isEmpty()) {
        ui->lineEditSerial->setStyleSheet("background: rgb(255, 204, 0);");
    } else {
        ui->lineEditSerial->setStyleSheet("");
    }
}

Furthermore, showInvalidInput() has to accomodate the new check, as shown below:

bool ConfiguratorWindow::showInvalidInput()
{
    bool retval = false;
    if (ui->lineEditSerial->text().isEmpty()) {  // Verification added in version 3.0
        ui->lineEditSerial->setStyleSheet("background: rgb(255, 102, 102);");
        retval = true;
    }
    ...
    return retval;
}