Skip to content

Editor refactor fixup #5528

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

Merged
merged 8 commits into from
Nov 9, 2016
Merged

Conversation

facchinm
Copy link
Member

Fixes some of the bugs emerged with recent Editor refactor.
@matthijskooijman @cmaglie take a look if you have some spare minutes (most fixes are trivial)
@per1234 could you test the build that @ArduinoBot will produce to confirm that #5402 and #5415 are gone? Thanks

ContributedPlatform referencedPlatform = indexer.getContributedPlaform(referenced);
if (referencedPlatform != null)
requiredTools.addAll(referencedPlatform.getResolvedTools());
if (referenced != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't an error be given when a referenced core does not exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmmh, good idea 😄
Compilation would fail anyway, so the problem should be solved by the maintainer (Arrow SAMD boards and Win10 IoT core are affected). However a message is ok, I'm pushing it tomorrow

Copy link
Collaborator

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

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

When first creating tabs, they are already sorted. Can we not re-use the sort criteria from there? Adding an additional comparator just for resorting the tabs on a change makes me think that these sorting criteria could diverge?

Also, is it really needed to resort whenever the tab menu is rebuilt? Is that the right place for the call to reorderTabs().

Finally, is the SketchFile object in the Sketch also inserted in the sorted position? If so, can we not reuse that position when creating the tab? If not, shouldn't the list of SketchFiles be synchronized with the list of tabs? I vaguely recall that there might be code that assumes the tab and sketch index are the same (though I probably tried to remove that as much as possible with my refactor).

@matthijskooijman
Copy link
Collaborator

@facchinm, I looked over the code and added some comments. Other than that, the commits look good to me. Thanks for diving into these!

@facchinm
Copy link
Member Author

The tab reordering code is not optimal; sketch list and tabs list are completely independent, but the first one gets ordered every time we add a tab, while the second one does not.
The reorderTabs function is there to avoid polluting the code with many calls for all situations; it actually executes something only if the sketch has changed, so the overhead is low (and in conjunction with 4e84238 it helps solving #5492).
However, if there was a way to avoid duplicating the comparator code it would be great 🙂

@matthijskooijman
Copy link
Collaborator

If the list of sketch files is already kept sorted, can't we use the position of a sketch file in the sketch file list as the position when creating a new tab? Or, whenever the list of sketch files changes, re-create the list of tabs or something?

@per1234
Copy link
Collaborator

per1234 commented Nov 2, 2016

@per1234 could you test the build that @ArduinoBot will produce to confirm that #5402 and #5415 are gone?

@facchinm, I confirm those issues are fixed with the test build(609). Thanks!

Previously it was selected always the last tab because the action
sequence was:

 - create the new tab (in the last position)
 - select the new tab index (last)
 - sort the tabs (the new tab is now in the middle but the selected
   is always the last)

instead the correct action sequence is

 - create the new tab (in the last position)
 - sort the tabs (now the new tab is in the middle)
 - select the new tab index (now the correct index is selected)
@cmaglie cmaglie added this to the Release 1.6.13 milestone Nov 7, 2016
@cmaglie
Copy link
Member

cmaglie commented Nov 7, 2016

  • added the error message when the referenced core is missing
  • solved the code duplication problem with a lambda
  • fixed a small bug (new tab is auto-selected after creation, before it was selected always the last one)

@cmaglie cmaglie modified the milestone: Release 1.6.13 Nov 7, 2016
@cmaglie cmaglie merged commit 10dcc1d into arduino:master Nov 9, 2016
@cmaglie cmaglie deleted the editor-refactor-fixup branch November 9, 2016 13:28
@matthijskooijman
Copy link
Collaborator

A bit late, but the extra commits look good to me :-)

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.

5 participants