MCP2210 Configurator (mcp2210-conf) is an application that allows you to fully configure MCP2210 devices, including VID, PID, and other descriptors, as well as pin functions and states.
GNU General Public License v3.0
0
stars
0
forks
source link
ConfiguratorWindow::handleError() should be simplified #2
Currently, the above mentioned function is implemented as follows:
// Determines the type of error and acts accordingly, always showing a message
void ConfiguratorWindow::handleError()
{
if (mcp2210_.disconnected() || !mcp2210_.isOpen()) {
disableView(); // Disable configurator window
mcp2210_.close(); // If the device is already closed, this will have no effect
}
QMessageBox::critical(this, tr("Error"), errmsg_);
}
The first if statement checks if the device got disconnected of if it is not open. However, in the case of this application, there is no need to check for the last condition, because the device is never reopened after being closed by the corresponding configurator window instance. Thus, the function above can be simplified:
// Determines the type of error and acts accordingly, always showing a message
void ConfiguratorWindow::handleError()
{
if (mcp2210_.disconnected()) {
disableView(); // Disable configurator window
mcp2210_.close(); // If the device is already closed, this will have no effect
}
QMessageBox::critical(this, tr("Error"), errmsg_);
}
Currently, the above mentioned function is implemented as follows:
The first if statement checks if the device got disconnected of if it is not open. However, in the case of this application, there is no need to check for the last condition, because the device is never reopened after being closed by the corresponding configurator window instance. Thus, the function above can be simplified: