Merge lp://qastaging/~azzar1/unity/filters-fixes into lp://qastaging/unity

Proposed by Andrea Azzarone
Status: Merged
Merged at revision: 1831
Proposed branch: lp://qastaging/~azzar1/unity/filters-fixes
Merge into: lp://qastaging/unity
Diff against target: 3803 lines (+1760/-1614)
29 files modified
UnityCore/RatingsFilter.cpp (+6/-4)
UnityCore/RatingsFilter.h (+1/-1)
manual-tests/AllButton.txt (+40/-0)
manual-tests/Filters.txt (+26/-0)
plugins/unityshell/resources/dash-widgets.json (+5/-5)
plugins/unityshell/src/FilterAllButton.cpp (+71/-0)
plugins/unityshell/src/FilterAllButton.h (+55/-0)
plugins/unityshell/src/FilterBar.cpp (+78/-67)
plugins/unityshell/src/FilterBar.h (+36/-31)
plugins/unityshell/src/FilterBasicButton.cpp (+116/-137)
plugins/unityshell/src/FilterBasicButton.h (+38/-34)
plugins/unityshell/src/FilterExpanderLabel.cpp (+124/-106)
plugins/unityshell/src/FilterExpanderLabel.h (+45/-38)
plugins/unityshell/src/FilterFactory.cpp (+44/-48)
plugins/unityshell/src/FilterFactory.h (+21/-15)
plugins/unityshell/src/FilterGenreButton.cpp (+49/-56)
plugins/unityshell/src/FilterGenreButton.h (+24/-24)
plugins/unityshell/src/FilterGenreWidget.cpp (+100/-131)
plugins/unityshell/src/FilterGenreWidget.h (+42/-44)
plugins/unityshell/src/FilterMultiRangeButton.cpp (+178/-184)
plugins/unityshell/src/FilterMultiRangeButton.h (+63/-58)
plugins/unityshell/src/FilterMultiRangeWidget.cpp (+145/-166)
plugins/unityshell/src/FilterMultiRangeWidget.h (+43/-43)
plugins/unityshell/src/FilterRatingsButton.cpp (+212/-233)
plugins/unityshell/src/FilterRatingsButton.h (+53/-51)
plugins/unityshell/src/FilterRatingsWidget.cpp (+58/-88)
plugins/unityshell/src/FilterRatingsWidget.h (+34/-41)
plugins/unityshell/src/FilterWidget.cpp (+38/-0)
plugins/unityshell/src/FilterWidget.h (+15/-9)
To merge this branch: bzr merge lp://qastaging/~azzar1/unity/filters-fixes
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Michal Hruby (community) lens-integration Approve
Mirco Müller Pending
Review via email: mp+85914@code.qastaging.launchpad.net

Commit message

Dash filters fixes.

Description of the change

First of all don't worry about the 3810 lines of diff because this is a update-coding-style branch too.

* Coding Style
  - Moves filters stuff in unity::dash:: namespace
  - Removes space between function name and (.
  - [Pointers] Place the asterisk adjacent to the type.
  - Adds UNITYSHELL_ prefix to each #define guard.
  - Uses nullptr

* Bug #838901

* Bug #841864
  - There is already a merge proposal [2] but it has too many conflicts so I've created my own patch with a quite different solution.
  - I've created a unity::Dash::FilterAllButton class to remove code duplication and to handle as clean as possible the "All" button design.
  - I've slightly changed UnityCore/RatingsFilter.cpp to make it working properly. Make check is ok after the change.

* Bug #841870
  - Sadly Area::SetVisible(bool) doesn't work with nux::Layout (by design and I've no idea why it is so...). So the best way to hide/unhide a nux::layout is to add/remove the layout to/from the parten layout.
  - When we remove the layout, we add a spacelayout to draw the separator line properly.

* Any other
 - I had this visual bug using unity from trunk [3]. Fixed it too.
 - I could not explain this...
      class FilterRatingsButton : public nux::Button, public unity::FilterWidget {
   Now it is:
      class FilterRatingsButton : public nux::ToggleButton {

[1] https://code.launchpad.net/~yeganeh/unity/fix-for-838901
[2] https://code.launchpad.net/~yeganeh/unity/fix-for-841864
[3] http://ubuntuone.com/7UM17vk7oa7m1paFbkKTfS

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Did you make sure this doesn't change the way the dbus signals are sent to lenses? (from looking at the changes it shouldn't though)

review: Needs Information
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Did you make sure this doesn't change the way the dbus signals are sent to
> lenses? (from looking at the changes it shouldn't though)

There's a TestRatingsFilter (or something like that) and it's ok after the changes.

The changes too UnityCore/RatingsFilter.cpp makes sure that after calling ::Clear the ratings is really setted to 0 (how happens with the other filters). The canges make sure that setting the ratings too 0 (or calling ::Clear) the filtering property is "setted" (quotation marks because it'a read only property) to false.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

*The changes to

Revision history for this message
Andrea Azzarone (azzar1) wrote :

Too many mistakes :/

> Did you make sure this doesn't change the way the dbus signals are sent to
> lenses? (from looking at the changes it shouldn't though)

There's a TestRatingsFilter (or something like that) and it's ok after the changes.

The changes to UnityCore/RatingsFilter.cpp make sure that after calling ::Clear the ratings property is really setted to 0 (how happens with the other filters). And the canges make sure that setting the ratings property to 0 (or calling ::Clear) the filtering property is "setted" (quotation marks because it'a read only property) to false.

Revision history for this message
Tim Penhey (thumper) wrote :

> - There is already a merge proposal [2] but it has too many conflicts so I've created my own patch with
> a quite different solution.

How is your solution different? Is there a good reason not to start with the existing proposal that gord had reviewed?

review: Needs Information
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> > - There is already a merge proposal [2] but it has too many conflicts so
> I've created my own patch with
> > a quite different solution.
>
> How is your solution different? Is there a good reason not to start with the
> existing proposal that gord had reviewed?

It's quite similar. The existing proposal uses a base class with an all button to remove duplicate in all the *widget.cpp files. My branch uses an all button class that is added using nux layout to the widget.

P.S. There was too many conflicts. I asked him to resolve them but I didn't get an answer.

Revision history for this message
Tim Penhey (thumper) wrote :
Download full text (6.3 KiB)

Another branch that really shouldn't have mixed style changes with real changes.

Use const& params when passing objects around, even smart pointers.

  void FilterAllButton::SetFilter(Filter::Ptr const& filter)

When would this method be called?

I know that you just moved the code, but FilterBasicButton.cpp,
FilterBasicButton::ComputeContentSize, should just set the cached_geometry_
inside the if statement, and reuse "geo".

Is there a reason we aren't using the cached_geometry_ in the Draw method?
Seems weird to cache it and not use it. Gah... and GetGeometry() is called
multiple times in Draw.

+1 on adding the missing & to const std::string. Extra brownie points for
making them "std::string const&" :-)

Inside FilterExpanderLabel::SetContents, you change the behaviour slightly.
Is this ever called more than once for any given object?

By calling SinkReference you are changing it from being unowned, to just
having a reference count of 1. When it is added to the layout, it gets a
reference count of 2. Normally when the layout is destroyed, it would
dereference. This is how the old code path handled the cleanup. The
SetContents method adds the unref, but doesn't remove the old contents from
the layout. However all of this is moot if this method should only ever be
called once.

Why add a SpaceLayout that isn't added to anything?

Also, we really shouldn't be adding Reference/UnReference/SinkReference calls
anywhere. Ideally you'd use a nux::ObjectPtr<xxx> to handle this.

Hmm... things becoming clearer.

You have a bug in your removal of the space layout.
  if (space_ and space_->IsChildOf(space_))
should be
  if (space_ and space_->IsChildOf(layout_))

> layout_->AddView(space_, 1);
I hate magic numbers in code, what does the "1" do?

If you changed the space_ and contents_ members to be nux::ObjectPtr wrappers,
you wouldn't need the the UnReference/SinkReference calls.

The SetContent method could then use the Adopt method to take ownership.

/me sighs

> nux::View* FilterFactory::WidgetForFilter(Filter::Ptr filter)

Please pass the filter by const&

This code will blow up if the filter type is not understood by trying to call
a method on a dynamic_cast of a nullptr.

Firstly, don't use nux::View* for the temporary. Use a FilterWidget* and call
it, oh maybe, widget. You also don't need to static_cast up an inheritance
hierarchy, you can just assign. Also, by doing this, you don't need the
dynamic_cast either.

  FilterWidget* widget = nullptr;
  if (filter_type == renderer_type_check_options)
  {
    widget = new FilterGenre(NUX_TRACKER_LOCATION);
  }
  else if (filter_type == renderer_type_ratings)
  {
    widget = new FilterRatingsWidget(NUX_TRACKER_LOCATION);
  }
  else if (filter_type == renderer_type_multirange)
  {
    widget = new FilterMultiRange(NUX_TRACKER_LOCATION);
  }
  else if (filter_type == renderer_type_radio_options)
  {
    widget = new FilterGenre(NUX_TRACKER_LOCATION);
  }
  else
  {
    LOG_WARNING(logger) << "Do not understand filter of type \""
                        << filter_type
                        << "\"";
  }

  if (widget)
    widget->SetFilter(filter);

  return widget;

> FilterFactory.h

A...

Read more...

review: Needs Fixing
Revision history for this message
Andrea Azzarone (azzar1) wrote :
Download full text (7.5 KiB)

> Another branch that really shouldn't have mixed style changes with real
> changes.
>
> Use const& params when passing objects around, even smart pointers.
>
> void FilterAllButton::SetFilter(Filter::Ptr const& filter)

Done.

>
> When would this method be called?

Every time the associated *Widget got another filter.

>
> I know that you just moved the code, but FilterBasicButton.cpp,
> FilterBasicButton::ComputeContentSize, should just set the cached_geometry_
> inside the if statement, and reuse "geo".

Done.

>
> Is there a reason we aren't using the cached_geometry_ in the Draw method?
> Seems weird to cache it and not use it. Gah... and GetGeometry() is called
> multiple times in Draw.

We're caching cached_geometry_ to not invalidate active_ and normal_ (?) every single time.
But I think that it's legal to use cached_geometry_ in the Draw method too... Maybe we can
ask Jay.

>
> +1 on adding the missing & to const std::string. Extra brownie points for
> making them "std::string const&" :-)
>
> Inside FilterExpanderLabel::SetContents, you change the behaviour slightly.

Because SetVisible doesn't work on a nux::layout ;)

> Is this ever called more than once for any given object?

It should be called just the first time.

>
> By calling SinkReference you are changing it from being unowned, to just
> having a reference count of 1. When it is added to the layout, it gets a
> reference count of 2. Normally when the layout is destroyed, it would
> dereference. This is how the old code path handled the cleanup. The
> SetContents method adds the unref, but doesn't remove the old contents from
> the layout. However all of this is moot if this method should only ever be
> called once.
>
> Why add a SpaceLayout that isn't added to anything?

It was necessary to add an extra padding during the collapse state. I've found a
cleaner solution ;)

>
> Also, we really shouldn't be adding Reference/UnReference/SinkReference calls
> anywhere. Ideally you'd use a nux::ObjectPtr<xxx> to handle this.

Done ;)

>
> Hmm... things becoming clearer.
>
> You have a bug in your removal of the space layout.
> if (space_ and space_->IsChildOf(space_))
> should be
> if (space_ and space_->IsChildOf(layout_))
>
> > layout_->AddView(space_, 1);
> I hate magic numbers in code, what does the "1" do?
>

No longer needed. I've just removed space_;

> If you changed the space_ and contents_ members to be nux::ObjectPtr wrappers,
> you wouldn't need the the UnReference/SinkReference calls.
>
> The SetContent method could then use the Adopt method to take ownership.

Done.

>
> /me sighs
>
> > nux::View* FilterFactory::WidgetForFilter(Filter::Ptr filter)
>
> Please pass the filter by const&

Done.

>
> This code will blow up if the filter type is not understood by trying to call
> a method on a dynamic_cast of a nullptr.

Done.

>
> Firstly, don't use nux::View* for the temporary. Use a FilterWidget* and call
> it, oh maybe, widget. You also don't need to static_cast up an inheritance
> hierarchy, you can just assign. Also, by doing this, you don't need the
> dynamic_cast either.
>
> FilterWidget* widget = nullptr;
> if (filter_typ...

Read more...

Revision history for this message
Tim Penhey (thumper) wrote :

The only change is to make the FilterWidget inherit from nux::View, then the FilterExpanderLabel inherits from FilterWidget. This will remove the multiple inheritance, and the need for the dynamic_cast in the factory method.

review: Needs Fixing
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> The only change is to make the FilterWidget inherit from nux::View, then the
> FilterExpanderLabel inherits from FilterWidget. This will remove the multiple
> inheritance, and the need for the dynamic_cast in the factory method.

Done.

Revision history for this message
Michal Hruby (mhr3) wrote :

Works well with latest libunity.

review: Approve (lens-integration)
Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.