Shadowed Variable Warnings (#1864)

Compile with ALL_WARNINGS using GCC 8.2.1.
Encountered approximately dozen warnings with this pattern:

    [path to sqlitebrowser root]/src/[somesourcefile]:line:cursor: warning: declaration
	of ‘data’ shadows a member of ‘ClassName’ [-Wshadow]
            OtherDataType data = ....line of code at line given above...
                          ^~~~
    In file included from /usr/include/qt5/QtWidgets/qdialog.h:44,
                     from /usr/include/qt5/QtWidgets/QDialog:1,
                     ...other sources in project
    /usr/include/qt5/QtWidgets/qwidget.h:733:18: note: shadowed declaration is here
         QWidgetData *data;
                      ^~~~

It appears there is a variable named 'data' within Qt global scope. Using 'data`
as a variable name, even one limited in scope to small lamda expressions, causes
compiler some grief.

Commit resolves the warnings in affected files. No problems apparent during execution.
Requires CSV stress-testing.
This commit is contained in:
Scott Furry
2019-05-07 14:09:21 -06:00
committed by Martin Kleusberg
parent 800a8daf11
commit d54b820fb2
6 changed files with 70 additions and 70 deletions

View File

@@ -687,8 +687,8 @@ QVariant::Type PlotDock::guessDataType(SqliteTableModel* model, int column)
QVariant::Type type = QVariant::Invalid;
for(int i = 0; i < std::min(10, model->rowCount()) && type != QVariant::String; ++i)
{
QVariant data = model->data(model->index(i, column), Qt::EditRole);
if(data.isNull() || data.convert(QVariant::Double))
QVariant varData = model->data(model->index(i, column), Qt::EditRole);
if(varData.isNull() || varData.convert(QVariant::Double))
{
type = QVariant::Double;
} else {