You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Mihai Chira <mi...@gmail.com> on 2015/05/22 16:28:36 UTC
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
I started to work on this and realised that this might be seen as a
pseudo-feature, rather than a bug. (To my mind it's a bug.) Pseudocode
for how it works now and how I think it should work:
1. NOW:
const sortByIndexAscending:Sort = new Sort();
sortByIndexAscending.fields = [new SortField("index", false, false, true)];
collection.sort = sortByIndexAscending;
collection.refresh(); //sorts
collection.sort.fields = [new SortField("name", false, true, false)];
//nothing happens
collection.getItemIndex(firstItemInCollection); //THROWS A RUNTIME
ERROR - see Jira ticket
2. SHOULD (but open to discussion, of course)
const sortByIndexAscending:Sort = new Sort();
sortByIndexAscending.fields = [new SortField("index", false, false, true)];
collection.sort = sortByIndexAscending;
collection.refresh(); //sorts
collection.sort.fields = [new SortField("name", false, true, false)];
//SORT HAPPENS AGAIN
collection.getItemIndex(firstItemInCollection); //works a treat
The only reason I can see why things should stay as they are is
because some people might have Sort objects that they're reusing
between collections, and might not realise that (after this change
happens) all their collections will resort once the fields change. To
me, though, it's not reason enough to keep this potential for runtime
errors.
Thoughts?
On 22 May 2015 at 16:19, Mihai Chira (JIRA) <ji...@apache.org> wrote:
>
> [ https://issues.apache.org/jira/browse/FLEX-34853?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Mihai Chira updated FLEX-34853:
> -------------------------------
> Issue Type: Bug (was: New Feature)
>
>> ListCollectionView.getItemIndex throws RTE when the Sort's sortFields change
>> ----------------------------------------------------------------------------
>>
>> Key: FLEX-34853
>> URL: https://issues.apache.org/jira/browse/FLEX-34853
>> Project: Apache Flex
>> Issue Type: Bug
>> Components: Collections, Spark: Sort and SortField
>> Affects Versions: Apache Flex 4.14.1
>> Reporter: Mihai Chira
>> Assignee: Mihai Chira
>> Fix For: Apache Flex 4.15.0
>>
>>
>> {code}
>> _sut.addAll(from4To0); //values["name"]: Object4, Object3, Object2, Object1, Object0
>> const sortByIndexAscending:Sort = new Sort();
>> sortByIndexAscending.fields = [new SortField("index", false, false, true)];
>> _sut.sort = sortByIndexAscending;
>> _sut.refresh(); //should be: Object0, Object1, Object2, Object3, Object4
>> //when
>> sortByIndexAscending.fields = [new SortField("name", false, true, false)]; //should have no effect
>> //then
>> assertThat(_sut.getItemIndex(from4To0.getItemAt(i)) != -1); //an RTE is thrown here
>> {code}
>> *Expected behaviour*: the collection should redo the sort when any of its sort's flags changes, or whenever one of the sortFields' flags changes.
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Mihai Chira <mi...@gmail.com>.
> collection.sort but nothing happens until the call refresh(). This is
> helpful if you have to make several changes to the sort (rather than just a
> one line change to sort.fields) as it avoids multiple re-sorts on a
> partially set up sort.
that's true, and in the vast majority of cases it can easily be
achieved by setting up all the Sort fields and flags at start, and
then just assigning it to the collection.
The big issue is that if refresh() isn't called at all, or in time (as
was the case with FLEX-34838[1]), then any calls to getItemIndex() or
removeItem() or removeAll() are very likely to throw errors, for
apparently mysterious reasons (the non-mysterious reason being that
the collection is using the new Sort options to search for items,
believing that they are correctly sorted with these options, rather
than the old ones).
[1] https://issues.apache.org/jira/browse/FLEX-34838
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
> sorry, how does that work? It sounds interesting.
Look at [1] and for instance line 157 or so starting with:
if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_6)
I know it’s going to be more complex in this case where you have methods signatures changing and properties access changing but there might be a way of doing it.
Thanks,
Justin
1. ./frameworks/projects/framework/src/mx/core/FlexVersion.as
2. ./frameworks/projects/spark/src/spark/layouts/VerticalLayout.as
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Mihai Chira <mi...@gmail.com>.
> It may also be an issue with 3rd party libraries that you don’t have the source code to that use sort code.
good point
> Possibly one option is to use the flex compatibility version so that people can set it to 4.15 to get the previous functionality.
sorry, how does that work? It sounds interesting.
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
It may also be an issue with 3rd party libraries that you don’t have the source code to that use sort code.
Possibly one option is to use the flex compatibility version so that people can set it to 4.15 to get the previous functionality.
Thanks,
Justin
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Mihai Chira <mi...@gmail.com>.
> Seems like you could just copy your current code into ImmutableSortField
sure, but ImmutableSortField would have the discovery problem - who
would know to use it - and wouldn't actually prevent any of the
fatals.
I will revert SortField and the other changes (tomorrow), and I'll
remove the ticket from the list for this release, so that gives us
time to find a solution with backwards compatibility, if at all (we
could even just say it's a known risk).
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Alex Harui <ah...@adobe.com>.
IMO, if someone tries to upgrade their app to a new SDK and they get
compile errors, they will complain and/or not upgrade. It does not make
us look good. They may not bother to even read why we did that.
Some people may have working apps where they do mutate the existing field
and call refresh().
Seems like you could just copy your current code into ImmutableSortField
and restore the old SortField. And you are welcome to add deprecation
metadata to the current SortField that tells folks that they are probably
better off using the new ImmutableSortField.
My 2 cents,
-Alex
On 11/7/16, 1:17 PM, "Mihai Chira" <mi...@gmail.com> wrote:
>> I guess I
>> don't fully understand the issue, so I don't have an alternate proposal,
>
>To help those reading this anew (but if responding, please also read
>the whole thread), the issue is:
>1. You have a sorted collection
>2. You change any of the properties of the Sort or SortField (the
>order, numeric or not, the field by which to sort, the sorting
>function, anything)
>3. You (or, more frequently, the SDK itself, through a component's
>dataProvider) call getItemIndex() or removeItem() or removeAll() on
>that collection.
>
>In this situation there will very likely be a fatal. Reason: refresh()
>wasn't called on the collection, so it (as the code is designed now)
>assumes that the collection has been sorted by the *modified* sorting
>rules, when in reality it's sorted by the original rules.
>
>There were 5 potential solutions suggested in the thread, and for the
>moment I chose the first one (making Sort and SortField immutable, but
>with an intermediary stage of hiding the state setters behind
>mx_internal for a few "transition" releases), thinking that the
>benefits of moving errors from the runtime to compile time is greater
>than strict backwards compatibility. (For the code changes this would
>imply, see FLEX-34880[1].)
>
>If, however, we decide that strict backwards compatibility is more
>important, I can revert the current changes (which achieved this for
>SortField; Sort was pending) and change course (but probably not for
>this impending release). If indeed it turns out this change is
>undesired, I can also go back and review the other solutions in more
>depth.
>
>For the record, I still personally think that sometimes it's ok to
>(minimally) break backwards compatibility (eventually, after a few
>transition releases) in favour of a better designed, less
>runtime-error prone framework which encourages better coding. What's
>good is that people upgrading their projects would get compile errors
>rather than changed behaviour at runtime, which is much harder to
>detect. And if we document these changes well, it should make it
>relatively easy to transition.
>
>[1] https://issues.apache.org/jira/browse/FLEX-34880
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Mihai Chira <mi...@gmail.com>.
> I guess I
> don't fully understand the issue, so I don't have an alternate proposal,
To help those reading this anew (but if responding, please also read
the whole thread), the issue is:
1. You have a sorted collection
2. You change any of the properties of the Sort or SortField (the
order, numeric or not, the field by which to sort, the sorting
function, anything)
3. You (or, more frequently, the SDK itself, through a component's
dataProvider) call getItemIndex() or removeItem() or removeAll() on
that collection.
In this situation there will very likely be a fatal. Reason: refresh()
wasn't called on the collection, so it (as the code is designed now)
assumes that the collection has been sorted by the *modified* sorting
rules, when in reality it's sorted by the original rules.
There were 5 potential solutions suggested in the thread, and for the
moment I chose the first one (making Sort and SortField immutable, but
with an intermediary stage of hiding the state setters behind
mx_internal for a few "transition" releases), thinking that the
benefits of moving errors from the runtime to compile time is greater
than strict backwards compatibility. (For the code changes this would
imply, see FLEX-34880[1].)
If, however, we decide that strict backwards compatibility is more
important, I can revert the current changes (which achieved this for
SortField; Sort was pending) and change course (but probably not for
this impending release). If indeed it turns out this change is
undesired, I can also go back and review the other solutions in more
depth.
For the record, I still personally think that sometimes it's ok to
(minimally) break backwards compatibility (eventually, after a few
transition releases) in favour of a better designed, less
runtime-error prone framework which encourages better coding. What's
good is that people upgrading their projects would get compile errors
rather than changed behaviour at runtime, which is much harder to
detect. And if we document these changes well, it should make it
relatively easy to transition.
[1] https://issues.apache.org/jira/browse/FLEX-34880
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Alex Harui <ah...@adobe.com>.
Reviving this thread...
IMO, breaking backward-compatibility is not helpful to Flex. I guess I
don't fully understand the issue, so I don't have an alternate proposal,
but I think having a separate set of Sort/SortFields that are immutable
should be considered.
-Alex
On 5/22/15, 9:49 AM, "Alex Harui" <ah...@adobe.com> wrote:
>
>
>On 5/22/15, 9:30 AM, "Mihai Chira" <mi...@gmail.com> wrote:
>
>>On 22 May 2015 at 17:38, Alex Harui <ah...@adobe.com> wrote:
>>> If you’ve been following the FlexJS stuff, you know that I am a
>>> “pay-as-you-go” advocate. I tend to lean against fancy code that,
>>>while
>>> it makes development faster, is still running at run-time.
>>I agree, which is why, after recalling some things I learned about
>>value objects from DDD[1] and other [2] places [3], I'm leaning toward
>>at least a partial implementation of #1, because Sort and SortField
>>have all the characteristics of value objects. This would change the
>>API somewhat, but only as much as requiring developers to create new
>>SortField or Sort objects if they want to apply different sorting
>>criteria.
>>
>>> You can say
>>> that a simple flag and the code to test whether to call refresh()
>>>doesn’t
>>> take many CPU cycles and you would be right, but the Flex SDK is
>>>evidence
>>> that when you add little bit of code like this thousands of times it
>>>adds
>>> up to something.
>>>
>>> So, my philosophy would be to think of ways to make sure folks don’t
>>> forget to call refresh().
>>...or reuse Sort / SortField objects between collections, which can
>>lead to the same problem. (Though if option #1 is implemented, reusing
>>them becomes safe, because their state cannot be changed.)
>
>I’m a little concerned that someone somewhere is relying on sharing a
>mutable SortField, so I’d be careful about making a change like that. At
>least, add an mx_internal flag to get back old behavior so if someone does
>complain they have a way of recovering.
>
>It might still be safer to implement a new set of Sort classes that are
>immutable.
>
>Anyway, be careful, and good luck.
>
>-Alex
>
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Mihai Chira <mi...@gmail.com>.
> I’m a little concerned that someone somewhere is relying on sharing a
> mutable SortField, so I’d be careful about making a change like that. At
> least, add an mx_internal flag to get back old behavior so if someone does
> complain they have a way of recovering.
Great idea. In the end I decided to go for a three-step process:
1) marking the setters and reverse() functions as deprecated (in
v4.15) - complete
2) placing them behind mx_internal (which includes renaming them) and
making reverse() work with immutable Sort and SortField objects (in
v4.16 - could you please create this version tag in Jira?)
3) completely removing the state setters (in 4.17)
This way people can have more time to adapt to the changes.
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Alex Harui <ah...@adobe.com>.
On 5/22/15, 9:30 AM, "Mihai Chira" <mi...@gmail.com> wrote:
>On 22 May 2015 at 17:38, Alex Harui <ah...@adobe.com> wrote:
>> If you’ve been following the FlexJS stuff, you know that I am a
>> “pay-as-you-go” advocate. I tend to lean against fancy code that, while
>> it makes development faster, is still running at run-time.
>I agree, which is why, after recalling some things I learned about
>value objects from DDD[1] and other [2] places [3], I'm leaning toward
>at least a partial implementation of #1, because Sort and SortField
>have all the characteristics of value objects. This would change the
>API somewhat, but only as much as requiring developers to create new
>SortField or Sort objects if they want to apply different sorting
>criteria.
>
>> You can say
>> that a simple flag and the code to test whether to call refresh()
>>doesn’t
>> take many CPU cycles and you would be right, but the Flex SDK is
>>evidence
>> that when you add little bit of code like this thousands of times it
>>adds
>> up to something.
>>
>> So, my philosophy would be to think of ways to make sure folks don’t
>> forget to call refresh().
>...or reuse Sort / SortField objects between collections, which can
>lead to the same problem. (Though if option #1 is implemented, reusing
>them becomes safe, because their state cannot be changed.)
I’m a little concerned that someone somewhere is relying on sharing a
mutable SortField, so I’d be careful about making a change like that. At
least, add an mx_internal flag to get back old behavior so if someone does
complain they have a way of recovering.
It might still be safer to implement a new set of Sort classes that are
immutable.
Anyway, be careful, and good luck.
-Alex
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Mihai Chira <mi...@gmail.com>.
On 22 May 2015 at 17:38, Alex Harui <ah...@adobe.com> wrote:
> If you’ve been following the FlexJS stuff, you know that I am a
> “pay-as-you-go” advocate. I tend to lean against fancy code that, while
> it makes development faster, is still running at run-time.
I agree, which is why, after recalling some things I learned about
value objects from DDD[1] and other [2] places [3], I'm leaning toward
at least a partial implementation of #1, because Sort and SortField
have all the characteristics of value objects. This would change the
API somewhat, but only as much as requiring developers to create new
SortField or Sort objects if they want to apply different sorting
criteria.
> You can say
> that a simple flag and the code to test whether to call refresh() doesn’t
> take many CPU cycles and you would be right, but the Flex SDK is evidence
> that when you add little bit of code like this thousands of times it adds
> up to something.
>
> So, my philosophy would be to think of ways to make sure folks don’t
> forget to call refresh().
...or reuse Sort / SortField objects between collections, which can
lead to the same problem. (Though if option #1 is implemented, reusing
them becomes safe, because their state cannot be changed.)
> In FlexJS, if we implement the same sort
> capability, we might have a “debug-mode” collection that throws a more
> useful error like “did you forget to call refresh()” where the
> “release-mode” collection doesn’t do that checking and thus runs smaller
> and faster.
>
> For the current Flex SDK, if you want to add another little bit of code
> like you suggest in #2 I won’t object because after a 1000 such changes,
> the 1001th change isn’t going to truly be noticed. I am only looking out
> for serious performance hits and breaking API behavior, so Tom’s warning
> about refreshing on every change is probably worth listening to.
>
> Adding try/catch around the point where getItemIndex throws the exception,
> detecting that a sort is in play and throwing a more useful exception
> message and/or adding a trace statement about calling refresh() would be
> an option #4.
Updating ASDocs to clarify this behaviour is definitely a good idea.
As for try/catch, I'd prefer to find a way to make it impossible to
get a runtime error in those functions (at least in these use cases).
> A new set of Sort classes that refresh on every change would be option #5.
I'll take that into consideration, good idea.
> Anyway, thanks for working on these issues,
> -Alex
No, thank you for these really useful comments.
[1] https://en.wikipedia.org/wiki/Domain-driven_design
[2] http://martinfowler.com/bliki/ValueObject.html
[3] http://stackoverflow.com/questions/4581579/value-objects-in-ddd-why-immutable
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Alex Harui <ah...@adobe.com>.
If you’ve been following the FlexJS stuff, you know that I am a
“pay-as-you-go” advocate. I tend to lean against fancy code that, while
it makes development faster, is still running at run-time. You can say
that a simple flag and the code to test whether to call refresh() doesn’t
take many CPU cycles and you would be right, but the Flex SDK is evidence
that when you add little bit of code like this thousands of times it adds
up to something.
So, my philosophy would be to think of ways to make sure folks don’t
forget to call refresh(). In FlexJS, if we implement the same sort
capability, we might have a “debug-mode” collection that throws a more
useful error like “did you forget to call refresh()” where the
“release-mode” collection doesn’t do that checking and thus runs smaller
and faster.
For the current Flex SDK, if you want to add another little bit of code
like you suggest in #2 I won’t object because after a 1000 such changes,
the 1001th change isn’t going to truly be noticed. I am only looking out
for serious performance hits and breaking API behavior, so Tom’s warning
about refreshing on every change is probably worth listening to.
Adding try/catch around the point where getItemIndex throws the exception,
detecting that a sort is in play and throwing a more useful exception
message and/or adding a trace statement about calling refresh() would be
an option #4.
A new set of Sort classes that refresh on every change would be option #5.
Anyway, thanks for working on these issues,
-Alex
On 5/22/15, 8:12 AM, "Mihai Chira" <mi...@gmail.com> wrote:
>> Folks keep trying to find ways to avoid calls to refresh() and we keep
>> ending up with other side-effects. Seems dangerous (from a backward
>> compatibility standpoint) to be making changes like this.
>When they do that they run into the risk of forgetting to call
>refresh() in time, or at all. Keep in mind that this sort of behaviour
>wasn't foreseen by SDK developers (for example when implementing
>FLEX-33248[1]), so application developers not familiar with the inner
>workings of the SDK are even more likely to run into these scenarios.
>To me bugs like FLEX-34838 should be avoided by making it impossible
>for developers to run into them. The possible solutions that I see
>are:
>1) make Sort and SortField immutable, thus forcing developers to
>create new instances to re-assign to collections, or
>2) get the collections to detect changes to Sort, SortField and
>filterFunction but only refresh() internally when getItemIndex(),
>removeItem() or removeItemAt() are called, or
>3) get the collections to detect changes to Sort, SortField and
>filterFunction and refresh immediately
>or some combination of the above, which can still allow developers to
>delay the collection's re-sorting/filtering, and also make these
>runtime errors a thing of the past.
>
>The way I see it is that to keep this potential for unintended
>behaviour in the SDK is to waste a lot of development time on
>debugging "weird" outcomes (I say a lot because they only become
>obvious at runtime, and under specific circumstances). It's these
>weird outcomes that we have a chance to make impossible in the first
>place, thus saving people time. The more we can move dangerous runtime
>errors to become compile errors the better.
>
>[1] https://issues.apache.org/jira/browse/FLEX-33248
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Mihai Chira <mi...@gmail.com>.
> Folks keep trying to find ways to avoid calls to refresh() and we keep
> ending up with other side-effects. Seems dangerous (from a backward
> compatibility standpoint) to be making changes like this.
When they do that they run into the risk of forgetting to call
refresh() in time, or at all. Keep in mind that this sort of behaviour
wasn't foreseen by SDK developers (for example when implementing
FLEX-33248[1]), so application developers not familiar with the inner
workings of the SDK are even more likely to run into these scenarios.
To me bugs like FLEX-34838 should be avoided by making it impossible
for developers to run into them. The possible solutions that I see
are:
1) make Sort and SortField immutable, thus forcing developers to
create new instances to re-assign to collections, or
2) get the collections to detect changes to Sort, SortField and
filterFunction but only refresh() internally when getItemIndex(),
removeItem() or removeItemAt() are called, or
3) get the collections to detect changes to Sort, SortField and
filterFunction and refresh immediately
or some combination of the above, which can still allow developers to
delay the collection's re-sorting/filtering, and also make these
runtime errors a thing of the past.
The way I see it is that to keep this potential for unintended
behaviour in the SDK is to waste a lot of development time on
debugging "weird" outcomes (I say a lot because they only become
obvious at runtime, and under specific circumstances). It's these
weird outcomes that we have a chance to make impossible in the first
place, thus saving people time. The more we can move dangerous runtime
errors to become compile errors the better.
[1] https://issues.apache.org/jira/browse/FLEX-33248
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Alex Harui <ah...@adobe.com>.
Folks keep trying to find ways to avoid calls to refresh() and we keep
ending up with other side-effects. Seems dangerous (from a backward
compatibility standpoint) to be making changes like this.
You could experiment with a new set of Sort classes that take a reference
to an LCV and auto-call refresh() on it as things change. That might get
you what you want and not break anybody.
-Alex
On 5/22/15, 7:33 AM, "Tom Chiverton" <tc...@extravision.com> wrote:
>I thought it was meant to work this way, you can do what you like to
>collection.sort but nothing happens until the call refresh(). This is
>helpful if you have to make several changes to the sort (rather than
>just a one line change to sort.fields) as it avoids multiple re-sorts on
>a partially set up sort.
>
>Tom
>
>On 22/05/15 15:28, Mihai Chira wrote:
>> I started to work on this and realised that this might be seen as a
>> pseudo-feature, rather than a bug. (To my mind it's a bug.) Pseudocode
>> for how it works now and how I think it should work:
>> 1. NOW:
>>
>> const sortByIndexAscending:Sort = new Sort();
>> sortByIndexAscending.fields = [new SortField("index", false, false,
>>true)];
>> collection.sort = sortByIndexAscending;
>> collection.refresh(); //sorts
>> collection.sort.fields = [new SortField("name", false, true, false)];
>> //nothing happens
>> collection.getItemIndex(firstItemInCollection); //THROWS A RUNTIME
>> ERROR - see Jira ticket
>>
>> 2. SHOULD (but open to discussion, of course)
>> const sortByIndexAscending:Sort = new Sort();
>> sortByIndexAscending.fields = [new SortField("index", false, false,
>>true)];
>> collection.sort = sortByIndexAscending;
>> collection.refresh(); //sorts
>> collection.sort.fields = [new SortField("name", false, true, false)];
>> //SORT HAPPENS AGAIN
>> collection.getItemIndex(firstItemInCollection); //works a treat
>>
>> The only reason I can see why things should stay as they are is
>> because some people might have Sort objects that they're reusing
>> between collections, and might not realise that (after this change
>> happens) all their collections will resort once the fields change. To
>> me, though, it's not reason enough to keep this potential for runtime
>> errors.
>>
>> Thoughts?
>>
>> On 22 May 2015 at 16:19, Mihai Chira (JIRA) <ji...@apache.org> wrote:
>>> [
>>>https://issues.apache.org/jira/browse/FLEX-34853?page=com.atlassian.jira
>>>.plugin.system.issuetabpanels:all-tabpanel ]
>>>
>>> Mihai Chira updated FLEX-34853:
>>> -------------------------------
>>> Issue Type: Bug (was: New Feature)
>>>
>>>> ListCollectionView.getItemIndex throws RTE when the Sort's sortFields
>>>>change
>>>>
>>>>-----------------------------------------------------------------------
>>>>-----
>>>>
>>>> Key: FLEX-34853
>>>> URL: https://issues.apache.org/jira/browse/FLEX-34853
>>>> Project: Apache Flex
>>>> Issue Type: Bug
>>>> Components: Collections, Spark: Sort and SortField
>>>> Affects Versions: Apache Flex 4.14.1
>>>> Reporter: Mihai Chira
>>>> Assignee: Mihai Chira
>>>> Fix For: Apache Flex 4.15.0
>>>>
>>>>
>>>> {code}
>>>> _sut.addAll(from4To0); //values["name"]: Object4,
>>>>Object3, Object2, Object1, Object0
>>>> const sortByIndexAscending:Sort = new Sort();
>>>> sortByIndexAscending.fields = [new SortField("index",
>>>>false, false, true)];
>>>> _sut.sort = sortByIndexAscending;
>>>> _sut.refresh(); //should be: Object0, Object1, Object2,
>>>>Object3, Object4
>>>> //when
>>>> sortByIndexAscending.fields = [new SortField("name",
>>>>false, true, false)]; //should have no effect
>>>> //then
>>>> assertThat(_sut.getItemIndex(from4To0.getItemAt(i)) !=
>>>>-1); //an RTE is thrown here
>>>> {code}
>>>> *Expected behaviour*: the collection should redo the sort when any of
>>>>its sort's flags changes, or whenever one of the sortFields' flags
>>>>changes.
>>>
>>>
>>> --
>>> This message was sent by Atlassian JIRA
>>> (v6.3.4#6332)
>> ______________________________________________________________________
>> This email has been scanned by the Symantec Email Security.cloud
>>service.
>> For more information please visit http://www.symanteccloud.com
>> ______________________________________________________________________
>>
>
Re: [jira] [Updated] (FLEX-34853) ListCollectionView.getItemIndex
throws RTE when the Sort's sortFields change
Posted by Tom Chiverton <tc...@extravision.com>.
I thought it was meant to work this way, you can do what you like to
collection.sort but nothing happens until the call refresh(). This is
helpful if you have to make several changes to the sort (rather than
just a one line change to sort.fields) as it avoids multiple re-sorts on
a partially set up sort.
Tom
On 22/05/15 15:28, Mihai Chira wrote:
> I started to work on this and realised that this might be seen as a
> pseudo-feature, rather than a bug. (To my mind it's a bug.) Pseudocode
> for how it works now and how I think it should work:
> 1. NOW:
>
> const sortByIndexAscending:Sort = new Sort();
> sortByIndexAscending.fields = [new SortField("index", false, false, true)];
> collection.sort = sortByIndexAscending;
> collection.refresh(); //sorts
> collection.sort.fields = [new SortField("name", false, true, false)];
> //nothing happens
> collection.getItemIndex(firstItemInCollection); //THROWS A RUNTIME
> ERROR - see Jira ticket
>
> 2. SHOULD (but open to discussion, of course)
> const sortByIndexAscending:Sort = new Sort();
> sortByIndexAscending.fields = [new SortField("index", false, false, true)];
> collection.sort = sortByIndexAscending;
> collection.refresh(); //sorts
> collection.sort.fields = [new SortField("name", false, true, false)];
> //SORT HAPPENS AGAIN
> collection.getItemIndex(firstItemInCollection); //works a treat
>
> The only reason I can see why things should stay as they are is
> because some people might have Sort objects that they're reusing
> between collections, and might not realise that (after this change
> happens) all their collections will resort once the fields change. To
> me, though, it's not reason enough to keep this potential for runtime
> errors.
>
> Thoughts?
>
> On 22 May 2015 at 16:19, Mihai Chira (JIRA) <ji...@apache.org> wrote:
>> [ https://issues.apache.org/jira/browse/FLEX-34853?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>>
>> Mihai Chira updated FLEX-34853:
>> -------------------------------
>> Issue Type: Bug (was: New Feature)
>>
>>> ListCollectionView.getItemIndex throws RTE when the Sort's sortFields change
>>> ----------------------------------------------------------------------------
>>>
>>> Key: FLEX-34853
>>> URL: https://issues.apache.org/jira/browse/FLEX-34853
>>> Project: Apache Flex
>>> Issue Type: Bug
>>> Components: Collections, Spark: Sort and SortField
>>> Affects Versions: Apache Flex 4.14.1
>>> Reporter: Mihai Chira
>>> Assignee: Mihai Chira
>>> Fix For: Apache Flex 4.15.0
>>>
>>>
>>> {code}
>>> _sut.addAll(from4To0); //values["name"]: Object4, Object3, Object2, Object1, Object0
>>> const sortByIndexAscending:Sort = new Sort();
>>> sortByIndexAscending.fields = [new SortField("index", false, false, true)];
>>> _sut.sort = sortByIndexAscending;
>>> _sut.refresh(); //should be: Object0, Object1, Object2, Object3, Object4
>>> //when
>>> sortByIndexAscending.fields = [new SortField("name", false, true, false)]; //should have no effect
>>> //then
>>> assertThat(_sut.getItemIndex(from4To0.getItemAt(i)) != -1); //an RTE is thrown here
>>> {code}
>>> *Expected behaviour*: the collection should redo the sort when any of its sort's flags changes, or whenever one of the sortFields' flags changes.
>>
>>
>> --
>> This message was sent by Atlassian JIRA
>> (v6.3.4#6332)
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
>