Fix an issue in TimeSeriesProperty#18952
Conversation
| { // so vectors can go out of scope | ||
| std::vector<DateAndTime> lhsTimes = this->timesAsVector(); | ||
| std::vector<DateAndTime> rhsTimes = right.timesAsVector(); | ||
| if (lhsTimes.size() != rhsTimes.size()) { |
There was a problem hiding this comment.
Shouldn't you use TimeSeriesProperty::size() or TimeSeriesProperty::realSize() and copy the vectors if they aren't equal?
There was a problem hiding this comment.
👍 maybe extend the if (this->m_size != right.m_size) above with an || this->realSize() != right.realSize(), then the check will be applied for both below
There was a problem hiding this comment.
The greatest effect would be had by putting this as an if on line 176.
There was a problem hiding this comment.
@peterfpeterson Could you tell me why an additional if is preferred to extending an existing one?
There was a problem hiding this comment.
Shouldn't they be the same? I've just added the additional because I find it easier to read.
|
I've tested without the fix and mantid crashes. After applying the fix there is no crash. |
| if (this->realSize() != right.realSize()) { | ||
| return false; | ||
| } | ||
|
|
There was a problem hiding this comment.
add the word else here and I'm happy
|
I think a clearer version of the code (with added if (this->realSize() != right.realSize()) {
return false;
} else {
const std::vector<DateAndTime> lhsTimes = this->timesAsVector();
const std::vector<DateAndTime> rhsTimes = right.timesAsVector();
if (!std::equal(lhsTimes.begin(), lhsTimes.end(), rhsTimes.begin())) {
return false;
}
const std::vector<TYPE> lhsValues = this->valuesAsVector();
const std::vector<TYPE> rhsValues = right.valuesAsVector();
if (!std::equal(lhsValues.begin(), lhsValues.end(), rhsValues.begin())) {
return false;
}
}
return true;I don't think the |
|
Tests are the usual unrelated failures. |
Re #18944 Fix the issue (cherry picked from commit 8880396) Re #18944 Added unit test (cherry picked from commit 291847a) Re #18944 Fix compiler warning about unused equality comparison result (cherry picked from commit c8bb2ae) Re #18944 Check size before getting times (cherry picked from commit 429775d) Re #18944 Adding else + const (cherry picked from commit 7de6a22) Add patch release note
Description of work.
To test:
Fixes #18944.
No need to mention this in the release notes, as the bug only happens on Windows in debug mode.
Reviewer
Please comment on the following (full description):
Code Review
Functional Tests
Do changes function as described? Add comments below that describe the tests performed?
How do the changes handle unexpected situations, e.g. bad input?
Has the relevant documentation been added/updated?
Is user-facing documentation written in a user-friendly manner?
Has developer documentation been updated if required?
Does everything look good? Comment with the ship it emoji but don't merge. A member of
@mantidproject/gatekeeperswill take care of it.