Skip to content

Commit bef856e

Browse files
committed
Fixes some problems reported by Coverity
- Unchecked dynamic_cast - Uninitialized scalar field - Uninitialized pointer field - Big parameter passed by value
1 parent 12c6a66 commit bef856e

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

src/AddRecordDialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class EditDelegate: public QStyledItemDelegate {
8282

8383
void setEditorData(QWidget *editor, const QModelIndex &index) const override {
8484

85-
NullLineEdit* lineEditor = dynamic_cast<NullLineEdit*>(editor);
85+
NullLineEdit* lineEditor = static_cast<NullLineEdit*>(editor);
8686
// Set the editor in the null state (unless the user has actually written NULL)
8787
if (index.model()->data(index, Qt::UserRole).isNull() &&
8888
index.model()->data(index, Qt::DisplayRole) == Settings::getValue("databrowser", "null_text"))
@@ -94,7 +94,7 @@ class EditDelegate: public QStyledItemDelegate {
9494
}
9595
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override {
9696

97-
NullLineEdit* lineEditor = dynamic_cast<NullLineEdit*>(editor);
97+
NullLineEdit* lineEditor = static_cast<NullLineEdit*>(editor);
9898
// Restore NULL text (unless the user has already modified the value)
9999
if (lineEditor->isNull() && !lineEditor->isModified()) {
100100
model->setData(index, Settings::getValue("databrowser", "null_text"), Qt::DisplayRole);

src/ExtendedScintilla.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222

2323
ExtendedScintilla::ExtendedScintilla(QWidget* parent) :
2424
QsciScintilla(parent),
25+
showErrorIndicators(true),
2526
findReplaceDialog(new FindReplaceDialog(this))
2627
{
2728
// This class does not set any lexer, that must be done in the child classes.
2829

2930
// Enable UTF8
3031
setUtf8(true);
3132

33+
3234
// Enable brace matching
3335
setBraceMatching(QsciScintilla::SloppyBraceMatch);
3436

src/FindReplaceDialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
FindReplaceDialog::FindReplaceDialog(QWidget* parent)
88
: QDialog(parent),
99
ui(new Ui::FindReplaceDialog),
10+
foundIndicatorNumber(0),
1011
findInProgress(false)
1112
{
1213
// Create UI

src/MainWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ void MainWindow::populateTable()
869869
QApplication::restoreOverrideCursor();
870870
}
871871

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

src/MainWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class MainWindow : public QMainWindow
184184

185185
sqlb::ObjectIdentifier currentlyBrowsedTableName() const;
186186

187-
void applyBrowseTableSettings(BrowseDataTableSettings storedData, bool skipFilters = false);
187+
void applyBrowseTableSettings(const BrowseDataTableSettings& storedData, bool skipFilters = false);
188188
void toggleTabVisible(QWidget* tabWidget, bool show);
189189
void restoreOpenTabs(QString tabs);
190190
QString saveOpenTabs();

0 commit comments

Comments
 (0)