Skip to content

Correctly remove old measures when downloading new ones#700

Merged
macumber merged 8 commits intodevelopfrom
fix_696
Mar 30, 2024
Merged

Correctly remove old measures when downloading new ones#700
macumber merged 8 commits intodevelopfrom
fix_696

Conversation

@macumber
Copy link
Copy Markdown
Collaborator

Properly remove components and measures of the old version, add missing pngs to qrc, don't remove all old measures after updating measures

Fixes #696

Behavior will be further improved with NatLabRockies/OpenStudio#5127

…ng pngs to qrc, don't remove all old measures after updating measures
@macumber macumber requested a review from jmarrec March 27, 2024 04:27
@macumber
Copy link
Copy Markdown
Collaborator Author

@jmarrec I'll test this some more before merging, let me know if you have any objections, it is in code near some of your changes.


std::vector<BCLComponent> OSDocument::getLocalComponents() const {
std::vector<BCLComponent> result;
if (m_haveLocalBCL) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm always thrown off by this ("Why would local bcl not be available") until I remember why we added it... )

return result;
}

std::vector<BCLComponent> OSDocument::getLocalComponents() const {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we need this.

Comment on lines +291 to +295
// remove old components
for (auto& oldComponent : OSAppBase::instance()->currentDocument()->getLocalComponents()) {
if ((oldComponent.uid() == component->uid()) && (oldComponent.versionId() != component->versionId())) {
LocalBCL::instance().removeComponent(oldComponent);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is looping on all components as opposed to using getLocalComponent(uid) better/needed?!

Copy link
Copy Markdown
Collaborator

@jmarrec jmarrec Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think I see. getComponent(uid) returns the first it finds

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to move this logic inside OSDocument where we do check if local bcl is available.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should just add new methods to OSDocument similar to what you added in NatLabRockies/OpenStudio#5129. We can update those to call the new methods when they become available.

Comment on lines +311 to +315
// remove old measures
for (auto& oldMeasure : OSAppBase::instance()->currentDocument()->getLocalMeasures()) {
if ((oldMeasure.uid() == measure->uid()) && (oldMeasure.versionId() != measure->versionId())) {
LocalBCL::instance().removeMeasure(oldMeasure);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question

Comment on lines -984 to -986
for (auto& oldMeasure : oldMeasures) {
LocalBCL::instance().removeMeasure(oldMeasure);
}
Copy link
Copy Markdown
Collaborator

@jmarrec jmarrec Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that's the actual fix? There's similar code a dozen lines below though.

for (auto& oldMeasure : oldMeasures) {
LocalBCL::instance().removeMeasure(oldMeasure);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If remoteBCL.updateMeasures(); works correctly then it will remove the outdated measures. However, that wasn't working reliably due to the issue you fixed in NatLabRockies/OpenStudio#5129. My guess is that I was seeing a case where the old measures weren't removed so I added this code in. However, this code fails when the new measures aren't fetched for some reason, the old ones will just be cleared. I assumed that is what was happening in the bug report.

jmarrec and others added 6 commits March 27, 2024 12:34
# Conflicts:
#	src/openstudio_lib/OSDocument.cpp
#	src/openstudio_lib/OSDocument.hpp
#	src/shared_gui_components/BuildingComponentDialogCentralWidget.cpp
#	src/shared_gui_components/MeasureManager.cpp
@macumber macumber merged commit 897c493 into develop Mar 30, 2024
@macumber macumber deleted the fix_696 branch March 30, 2024 15:08
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local copy of BCL folder gets wiped/overwritten

2 participants