Object list window: allow massive focus setting

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Object list window: allow massive focus setting

#31 Post by vincele »

Yes, it's kind of duplicating some functionality that I either don't understand, either don't work, or something else...

The obvious :

Code: Select all

[...]
const GG::ListBox::SelectionSet sels = m_list_box->Selections();
Refresh();
m_list_box->SetSelections(sels);
[...]
Is segfaulting right away at me. And I thought it would be easier/safer to remember the planet ids and reselect those than try to debug/understand Gigi (as I'm dumb *AND* lazy :-) )...

I think it's because the Refresh() call clear()s the listbox content, which is then recreated and so the saved references get unusable, but I may be remembering it all wrong...

If you know a way to make it work, please tell and I'll try but this patch is "works-for-me", so...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Object list window: allow massive focus setting

#32 Post by vincele »

The segfault happens at GG/src/ListBox.cpp:709
We're calling GG::Wnd::Height() on previous selection's items, which are now nulls...

So someone would like to invest time digging into gigi's innards ?

I still think my solution (working around gigi's deficiencies) is logically good, because ObjectListBox::Refresh() calls Clear(), we cannot reuse the previous selection as-is.

The alternative: making ObjectListBox::Refresh() NOT call Clear() looks way more involved, and not the kind of thing I want to engage into right now...

A middle ground could be (ugly) : opencode my ID-based selection save/restore inside Refresh(), around the ClearContent() call. Would you prefer that ?
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Object list window: allow massive focus setting

#33 Post by Geoff the Medio »

Looks like your method is quite similar to what's done in FleetWnd::Refresh(), except that uses member functions of FleetWnd instead of free functions. Could you move the functions that get the selected object ids and set them to a passed in set into ObjectListWnd, and rename them to ObjectListWnd::SelectedObjectIDs and ObjectListWnd::SetSelectedObjects? This avoids needing to pass in a pointer to the ListBox, which is a bit misleading currently as it takes a ListBox* and not an ObjectListWnd* despite only really being able to handle the latter.

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Object list window: allow massive focus setting

#34 Post by vincele »

This one should be better

[The extension diff has been deactivated and can no longer be displayed.]

All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Object list window: allow massive focus setting

#35 Post by Geoff the Medio »

Looks OK (though didn't test, and assuming that method allows multiple selected rows to be restored). Can't do anything about committing it now though as sourceforge SVN is down...

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Object list window: allow massive focus setting

#36 Post by vincele »

Geoff the Medio wrote:Looks OK (though didn't test, and assuming that method allows multiple selected rows to be restored). Can't do anything about committing it now though as sourceforge SVN is down...
It's lightly tested, and works as intended for multiselection. No rush for commit, I've seen the sf.net problems, and am currently on holidays...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Object list window: allow massive focus setting

#37 Post by Geoff the Medio »


User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Object list window: allow massive focus setting

#38 Post by vincele »

Thx
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

Post Reply