Index: sources/model/MListModel.cpp =================================================================== diff -u -r0c3a39a834f3e3f9c760c8ca87f95c14044842e2 -rd29bb07a1420af33b6cd892d395fc7bc093aa1ae --- sources/model/MListModel.cpp (.../MListModel.cpp) (revision 0c3a39a834f3e3f9c760c8ca87f95c14044842e2) +++ sources/model/MListModel.cpp (.../MListModel.cpp) (revision d29bb07a1420af33b6cd892d395fc7bc093aa1ae) @@ -40,22 +40,23 @@ */ QVariant View::MListModel::data(const QModelIndex &vIndex, int vRole) const { + QVariant mData; + // check for invalid or out of bounds index - if ( ! vIndex.isValid() || vIndex.row() >= rowCount()) { - return QVariant(); - } + if ( ! vIndex.isValid() || vIndex.row() >= rowCount()) { goto lOut; } // ensure the data is not empty - if ( _data.isEmpty() ) { return QVariant(); } + if ( _data.isEmpty() ) { goto lOut; } // ensure the role is in the data - if ( _data[vIndex.row()].find(vRole) == _data[vIndex.row()].end()) { return QVariant(); } + if ( _data[vIndex.row()].find(vRole) == _data[vIndex.row()].end()) { goto lOut; } - QVariant mData = _data[vIndex.row()][vRole]; + mData = _data[vIndex.row()][vRole]; // check if data is valid - if (! mData.isValid()) { return QVariant(); } + if (! mData.isValid()) { goto lOut; } +lOut: return mData; } @@ -65,15 +66,16 @@ */ QVariantMap View::MListModel::get(int vRow) const { + QVariantMap map; + // Row bounds check - if (vRow < 0 || vRow >= rowCount()) { return {}; } + if (vRow < 0 || vRow >= rowCount()) { goto lOut; } QHash roles = roleNames(); // Check if roles are defined - if ( roles.isEmpty() ) { return {}; } + if ( roles.isEmpty() ) { goto lOut; } - QVariantMap map; for (auto it = roles.cbegin(); it != roles.cend(); ++it) { const int role = it.key(); const QByteArray roleName = it.value();