summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2018-10-30 07:24:24 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2018-11-14 10:35:55 (GMT)
commit30639ed8dbb419890eab5a0b46d3a78896c7f22d (patch)
tree62b7a3b19bc3d84bfc0a0d4ac71a79beb0946e8c /Swift/Controllers/Roster
parent5758cc48f5f340132d19e79f647dd5d3ad8c54fc (diff)
downloadswift-30639ed8dbb419890eab5a0b46d3a78896c7f22d.zip
swift-30639ed8dbb419890eab5a0b46d3a78896c7f22d.tar.bz2
Fix various uses of numeric_cast in UI bits
Apart from QtUI bits, this addresses use of uncaught numeric cast exceptions in message count handling, the spell parser and the MacOS idle querier. The WindowsServicePrincipalName logic previously had an issue where using ports from 32768 onwards would result in a bad_numeric_cast exception to be thrown. This has been addressed at the same time as the uncaught exceptions, and all ports should work now. The tags file has been extended to ignore more files. Change-Id: I73ced35f06517bee5c58f990d20fa437b40ac84e
Diffstat (limited to 'Swift/Controllers/Roster')
-rw-r--r--Swift/Controllers/Roster/LeastCommonSubsequence.h4
-rw-r--r--Swift/Controllers/Roster/TableRoster.cpp25
2 files changed, 17 insertions, 12 deletions
diff --git a/Swift/Controllers/Roster/LeastCommonSubsequence.h b/Swift/Controllers/Roster/LeastCommonSubsequence.h
index 8daa20c..7988ee7 100644
--- a/Swift/Controllers/Roster/LeastCommonSubsequence.h
+++ b/Swift/Controllers/Roster/LeastCommonSubsequence.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2011-2016 Isode Limited. 2 * Copyright (c) 2011-2018 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -32,7 +32,7 @@ namespace Swift {
32 Predicate predicate; 32 Predicate predicate;
33 for (size_t i = 1; i < width; ++i) { 33 for (size_t i = 1; i < width; ++i) {
34 for (size_t j = 1; j < height; ++j) { 34 for (size_t j = 1; j < height; ++j) {
35 result[i + j*width] = predicate(*(xBegin + boost::numeric_cast<long long>(i)-1), *(yBegin + boost::numeric_cast<long long >(j)-1)) ? result[(i-1) + (j-1)*width] + 1 : std::max(result[i + (j-1)*width], result[i-1 + (j*width)]); 35 result[i + j*width] = predicate(*(xBegin + static_cast<long long>(i)-1), *(yBegin + static_cast<long long>(j)-1)) ? result[(i-1) + (j-1)*width] + 1 : std::max(result[i + (j-1)*width], result[i-1 + (j*width)]);
36 } 36 }
37 } 37 }
38 } 38 }
diff --git a/Swift/Controllers/Roster/TableRoster.cpp b/Swift/Controllers/Roster/TableRoster.cpp
index 713f390..01bf4a6 100644
--- a/Swift/Controllers/Roster/TableRoster.cpp
+++ b/Swift/Controllers/Roster/TableRoster.cpp
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2011-2016 Isode Limited. 2 * Copyright (c) 2011-2018 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -132,15 +132,20 @@ void TableRoster::handleUpdateTimerTick() {
132 std::vector<size_t> itemRemoves; 132 std::vector<size_t> itemRemoves;
133 std::vector<size_t> itemInserts; 133 std::vector<size_t> itemInserts;
134 computeIndexDiff<Item, ItemEquals, ItemNeedsUpdate >(sections[sectionUpdates[i]].items, newSections[sectionPostUpdates[i]].items, itemUpdates, itemPostUpdates, itemRemoves, itemInserts); 134 computeIndexDiff<Item, ItemEquals, ItemNeedsUpdate >(sections[sectionUpdates[i]].items, newSections[sectionPostUpdates[i]].items, itemUpdates, itemPostUpdates, itemRemoves, itemInserts);
135 size_t end = update.insertedRows.size(); 135 try {
136 update.insertedRows.resize(update.insertedRows.size() + itemInserts.size()); 136 size_t end = update.insertedRows.size();
137 std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); 137 update.insertedRows.resize(update.insertedRows.size() + itemInserts.size());
138 end = update.deletedRows.size(); 138 std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i]));
139 update.deletedRows.resize(update.deletedRows.size() + itemRemoves.size()); 139 end = update.deletedRows.size();
140 std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionUpdates[i])); 140 update.deletedRows.resize(update.deletedRows.size() + itemRemoves.size());
141 end = update.updatedRows.size(); 141 std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionUpdates[i]));
142 update.updatedRows.resize(update.updatedRows.size() + itemUpdates.size()); 142 end = update.updatedRows.size();
143 std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); 143 update.updatedRows.resize(update.updatedRows.size() + itemUpdates.size());
144 std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i]));
145 }
146 catch (const boost::numeric::bad_numeric_cast&) {
147 // If any container claims it has more than long long max items, we have bigger issues, so letting this pass
148 }
144 } 149 }
145 150
146 // Switch the old model with the new 151 // Switch the old model with the new