Fixes some problems reported by Coverity

- Unchecked dynamic_cast
- Uninitialized scalar field
- Uninitialized pointer field
- Big parameter passed by value
This commit is contained in:
mgrojo
2019-08-02 17:19:28 +02:00
parent 12c6a66375
commit bef856ef45
5 changed files with 7 additions and 4 deletions

View File

@@ -82,7 +82,7 @@ public:
void setEditorData(QWidget *editor, const QModelIndex &index) const override {
NullLineEdit* lineEditor = dynamic_cast<NullLineEdit*>(editor);
NullLineEdit* lineEditor = static_cast<NullLineEdit*>(editor);
// Set the editor in the null state (unless the user has actually written NULL)
if (index.model()->data(index, Qt::UserRole).isNull() &&
index.model()->data(index, Qt::DisplayRole) == Settings::getValue("databrowser", "null_text"))
@@ -94,7 +94,7 @@ public:
}
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override {
NullLineEdit* lineEditor = dynamic_cast<NullLineEdit*>(editor);
NullLineEdit* lineEditor = static_cast<NullLineEdit*>(editor);
// Restore NULL text (unless the user has already modified the value)
if (lineEditor->isNull() && !lineEditor->isModified()) {
model->setData(index, Settings::getValue("databrowser", "null_text"), Qt::DisplayRole);

View File

@@ -22,6 +22,7 @@
ExtendedScintilla::ExtendedScintilla(QWidget* parent) :
QsciScintilla(parent),
showErrorIndicators(true),
findReplaceDialog(new FindReplaceDialog(this))
{
// This class does not set any lexer, that must be done in the child classes.
@@ -29,6 +30,7 @@ ExtendedScintilla::ExtendedScintilla(QWidget* parent) :
// Enable UTF8
setUtf8(true);
// Enable brace matching
setBraceMatching(QsciScintilla::SloppyBraceMatch);

View File

@@ -7,6 +7,7 @@
FindReplaceDialog::FindReplaceDialog(QWidget* parent)
: QDialog(parent),
ui(new Ui::FindReplaceDialog),
foundIndicatorNumber(0),
findInProgress(false)
{
// Create UI

View File

@@ -869,7 +869,7 @@ void MainWindow::populateTable()
QApplication::restoreOverrideCursor();
}
void MainWindow::applyBrowseTableSettings(BrowseDataTableSettings storedData, bool skipFilters)
void MainWindow::applyBrowseTableSettings(const BrowseDataTableSettings& storedData, bool skipFilters)
{
// We don't want to pass storedData by reference because the functions below would change the referenced data in their original
// place, thus modifiying the data this function can use. To have a static description of what the view should look like we want

View File

@@ -184,7 +184,7 @@ private:
sqlb::ObjectIdentifier currentlyBrowsedTableName() const;
void applyBrowseTableSettings(BrowseDataTableSettings storedData, bool skipFilters = false);
void applyBrowseTableSettings(const BrowseDataTableSettings& storedData, bool skipFilters = false);
void toggleTabVisible(QWidget* tabWidget, bool show);
void restoreOpenTabs(QString tabs);
QString saveOpenTabs();