Skip to content

Resource Downloading - #1298

Merged
jw098 merged 3 commits into
PokemonAutomation:mainfrom
jw098:download3
Jul 13, 2026
Merged

Resource Downloading#1298
jw098 merged 3 commits into
PokemonAutomation:mainfrom
jw098:download3

Conversation

@jw098

@jw098 jw098 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@jw098
jw098 marked this pull request as draft June 23, 2026 06:54
@jw098
jw098 marked this pull request as ready for review July 8, 2026 00:36
@jw098

jw098 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

This PR is now ready to be reviewed. Let me know if you want the PR to be split up.

if (current_state() != ProgramState::RUNNING){
return;
}
m_scope.store(&scope, std::memory_order_release);

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 should really redesign this m_scope mechanism here. I hate. But that's for a future cleanup.

}

void SingleSwitchProgramWidget2::download_added(std::shared_ptr<ResourceDownload> download_ptr){
QMetaObject::invokeMethod(this, [this, download_ptr]{

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 wonder if this works:

QMetaObject::invokeMethod(this, [this, download_ptr = std::move(download_ptr)]{

This moves it into the lambda instead of copying.

Same with the other places.

m_actions_bar = new RunnablePanelActionBar(*this, m_session.current_state());
layout->addWidget(m_actions_bar);

m_downloads_table = new ProgramResourceDownloadTableWidget(*this);

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 wonder if this should be done lazily (on first use). The vast majority of programs won't need this. So unconditionally instantiating its sounds wasteful especially since the widget is non-trivial.

Don't need to do anything about it in this PR since it's big enough. Maybe a future cleanup.


void ProgramMissingResourceTracker::add_resource(const std::shared_ptr<ResourceDownload>& resource){
m_missing_resources.insert(resource);
resource->add_listener(*this);

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.

If add_listener() throw here, you'll be left in a bad state which I think will hang.

I suggest wrapping it in an exception and if it throws, remove the resource (undo the 1st line) and rethrow exception.

@jw098
jw098 merged commit c699340 into PokemonAutomation:main Jul 13, 2026
7 checks passed
@jw098
jw098 deleted the download3 branch July 13, 2026 05:25
Developer-Butters pushed a commit to Developer-Butters/Arduino-Source that referenced this pull request Jul 28, 2026
* squash changes

* update StaticRegistrationQt

* minor change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants