Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up BCL dialog and remove auth keys #447

Merged
merged 10 commits into from
Oct 29, 2021
Merged

Clean up BCL dialog and remove auth keys #447

merged 10 commits into from
Oct 29, 2021

Conversation

macumber
Copy link
Collaborator

Fixes #408

src/openstudio_lib/OSDocument.cpp Show resolved Hide resolved
Comment on lines +88 to +89
QTimer* m_timer;
QElapsedTimer m_downloadTimer;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll need to double check this, feels weird that one is a pointer and the other isn't.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree its weird but QElapsedTimer doesn't take a parent in the ctor so it doesn't get cleaned up automatically. I could make it a shared pointer.

Comment on lines +342 to +343
m_checkBox->style()->unpolish(m_checkBox);
m_checkBox->style()->polish(m_checkBox);
Copy link
Collaborator

Choose a reason for hiding this comment

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

unpolish / polish?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is necessary to redraw the check box indicator (e.g. to show that a component has been downloaded). For some reason setObjectName doesn't change the appearance of the object unless you call this:

https://stackoverflow.com/questions/32083311/why-does-my-qwidget-stylesheet-not-recognise-objectname-rules

Comment on lines +93 to +99
BuildingComponentDialogCentralWidget::~BuildingComponentDialogCentralWidget() {
m_timer->stop();
clearPendingDownloads(false);
if (m_remoteBCL) {
m_remoteBCL->waitForComponentDownload();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems like a sensible thing the destructor should do.

Comment on lines +102 to +104
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, this, &BuildingComponentDialogCentralWidget::downloadNextComponent);
m_timer->start(500);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you explain this part please?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused, even after looking at the code I still don't get how downloadNextComponent is called over and over again?! (maybe it is not...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see. init starts a timer, everytime a download is done, another timer of 500 is started...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I had a lot of trouble here. I don't think RemoteBCL actually works to download multiple components, it seems to only work for the first download, I didn't track down why. Also, if multiple RemoteBCL objects download at the same time, the downloads will complete but the entries will not get inserted into LocalBCL. I think LocalBCL is not fully threadsafe. So I had a queue of components to download and used a timer to check the queue every 500 ms.

m_currentDownload = m_pendingDownloads.front();
m_pendingDownloads.pop();
if (m_currentDownload->second == "components") {
m_remoteBCL = std::make_shared<RemoteBCL>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It pains me a little to see that even if everything is going well (components/measures are downloading all fine) we are destroying then recreating the a RemoteBCL instance, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree, but I think this is an issue with RemoteBCL.

m_progressBar->setVisible(false);
m_showNewComponents = true;
}
m_remoteBCL.reset();
Copy link
Collaborator

Choose a reason for hiding this comment

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

we could check if m_pendingDownloads is empty or something before resetting it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When we get here, the current download has completed so we destroy this m_remoteBCL instance. A new m_remoteBCL instance will be created the next time downloadNextComponent is called.

src/openstudio_lib/OSDocument.cpp Outdated Show resolved Hide resolved
@jmarrec
Copy link
Collaborator

jmarrec commented Oct 26, 2021

@macumber I changed the progressBar in bfeaa0a

447_progress

// show busy progress: we add 1 to both Value and Maximum to immediately indicate to the user that we started doing *something*
m_progressBar->setValue(m_totalPendingDownloads - m_pendingDownloads.size());
m_progressBar->setMinimum(0);
m_progressBar->setMaximum(m_totalPendingDownloads + 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jmarrec nice, I missed that we could do that now

@@ -1697,7 +1697,7 @@ std::shared_ptr<MainRightColumnController> OSDocument::mainRightColumnController
}

void OSDocument::openMeasuresBclDlg() {
if (RemoteBCL::isOnline()) {
if (!RemoteBCL::isOnline()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jmarrec thanks for catching this

@jmarrec jmarrec merged commit 75b8192 into develop Oct 29, 2021
@jmarrec jmarrec deleted the fix_408 branch October 29, 2021 07:47
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to BCL v2
2 participants