Skip to content

Make sure Launch Bar Manager sends event at a correct time#1486

Draft
DangMinhTam382 wants to merge 2 commits into
eclipse-cdt:mainfrom
DangMinhTam382:LaunchBarNewEvent
Draft

Make sure Launch Bar Manager sends event at a correct time#1486
DangMinhTam382 wants to merge 2 commits into
eclipse-cdt:mainfrom
DangMinhTam382:LaunchBarNewEvent

Conversation

@DangMinhTam382

Copy link
Copy Markdown
Contributor

When active descriptor changed, and fireActiveLaunchDescriptorChanged() is called, current active mode and target are out of sync. This puts listeners at risk of handling event with false data for the changed descriptor.

Changed it so that only fire event when related fields are finished updating

When active descriptor changed, and fireActiveLaunchDescriptorChanged()
is called, current active mode and target are out of sync. This puts
listeners at risk of handling event with false data for the changed
descriptor.

Changed it so that only fire event when related fields are finished
updating
@github-actions

Copy link
Copy Markdown

Test Results

4 718 tests  ±0   4 709 ✅ ±0   2m 44s ⏱️ +14s
  182 suites ±0       9 💤 ±0 
  182 files   ±0       0 ❌ ±0 

Results for commit 571f0e4. ± Comparison against base commit 869651b.

@DangMinhTam382

Copy link
Copy Markdown
Contributor Author

Hi Mr. @betamaxbandit ,
CC: Mr. @Kummallinen ,

Before making this PR official, could you take a quick look and let me know what you think?

Thanks!

// Set active mode
syncActiveMode();
// Send notifications
fireActiveLaunchDescriptorChanged();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just moving this doesn't really solve the issue, the events for target & mode are still sent too early. This was why I suggested we create a new event that was for when any of them changed then we can just fire that once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment, Mr. @Kummallinen

About your suggestion, I did spend quite some time testing it out.
Tried posting a "LaunchBarChanged" event at the very end of these 3 methods: "setActiveLaunchDescriptor()", "setActiveLaunchMode()", "setActiveLaunchTarget()".
And it worked.

Then I realized that existing events "activeLaunchTargetChanged" & "activeLaunchModeChanged" are sent at the same point as the newly added event. The only exception is "activeLauchDescriptorChanged", which is fired too early.
With the changes in this commit, all three existing events and the new event are sent at the same time.

From an event-handling perspective, there is no noticeable difference between the existing events and the new event. That's why I decided to go with the approach in this commit.

--
About your concern:

the events for target & mode are still sent too early

Since "syncActiveTarget()" and "syncActiveMode()" is calling to "setActiveLaunchMode()" and "setActiveLaunchTarget()", respectively, the change events would still be fired too early even with the new event.

-> Possible suggestion to fix for this would be creating internal method that does NOT fire event,
Ex:
"syncActiveTarget()" -> "internalSetActiveLaunchTarget()" -> "internalSetActiveLaunchMode()"
However, this would be a much larger change and could potentially impact existing ISV implementations that relies on the current event behavior.

Therefore, instead of trying to ensure that events are fired at desired time, this commit focuses on ensuring that all Launch Bar components are up to date when a change event is fired/caught, even if the triggering method has not yet finished executing.

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