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

Device information functionality may present an empty error message #43

Closed samuelfmlourenco closed 2 months ago

samuelfmlourenco commented 4 months ago

When calling Device > Information, an empty error message may be shown. This is exemplified by the image below:

InformationDialogEmptyError

At a first glance, this error is caused by the fact that bool "err_", a variable that is global to every instance of ConfiguratorWindow instance, is never initialized. This variable is declared in "configurationwindow.h", line 94:

bool err_, requiresReset_, viewEnabled_ = false;

However, where this variable is to be initialized is pending analysis. Probably, the variable should be initialized locally inside the ConfiguratorWindow::on_actionInformation_triggered(), but further studying is required.

samuelfmlourenco commented 4 months ago

The solution is to initialize "err_" inside ConfiguratorWindow::on_actionInformation_triggered(), as follows:

void ConfiguratorWindow::on_actionInformation_triggered()
{
    if (informationDialog_.isNull()) {  // If the dialog is not open (implemented in version 2.0, because the device information dialog is now modeless)
        err_ = false;  // Bug fix
        int errcnt = 0;
        QString errstr;
        CP2130::SiliconVersion siversion = cp2130_.getSiliconVersion(errcnt, errstr);
        opCheck(tr("device-information-retrieval-op"), errcnt, errstr);  // The string "device-information-retrieval-op" should be translated to "Device information retrieval"
        if (err_) {  // Fix implemented in version 1.2
            handleError();
        } else {  // If error check passes
            informationDialog_ = new InformationDialog(this);  // The dialog is no longer modal (version 2.0 feature);
            informationDialog_->setAttribute(Qt::WA_DeleteOnClose);  // It is important to delete the dialog in memory once closed, in order to force the application to retrieve information about the device if the window is opened again
            informationDialog_->setWindowTitle(tr("Device Information (S/N: %1)").arg(serialstr_));
            informationDialog_->setSiliconVersionValueLabelText(siversion.maj, siversion.min);
            informationDialog_->show();
        }
    } else {
        informationDialog_->showNormal();  // Required if the dialog is minimized
        informationDialog_->activateWindow();  // Set focus on the previous dialog (dialog is raised and selected)
    }
}
samuelfmlourenco commented 2 months ago

Fixed in version 3.0.