Kirix Support Forums

SavePerspective/LoadPerspective issues

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

SavePerspective/LoadPerspective issues

Postby Les Newell on Fri Feb 16, 2007 2:20 pm

Hi,

I have been playing with wxAUI and I think it is great. However have hit a few problems when saving and loading perspectives.

Say I create an application and save the perspective when it closes. Next time I start the application it automatically loads the perspective and everything works fine.

Now I change my program an add another pane. When I start my application the new pane does not appear. If I don't call LoadPerspective the pane shows correctly.

The reason for this is in the way LoadPerspective works. It first hides all panes then loads the perspective. If there is a pane missing in the perspective then that pane stays hidden. This isn't too bad if the pane is optional but if it is supposed to always be visible then it can be a real problem.

It gets worse if I remove a pane from my program and try to load an existing perspective. Half my panes now disappear! This is because LoadPerspective immediately exits if it finds a pane in the perspective that does not actually exist.

For me these problems make perspectives completely useless. If there are any changes to the program the user has to edit/delete his settings to get the display to work.

Also looking at the saved data, IMHO there is some data that should not be saved. For instance why save the caption, best size, max size etc? If any panes are ever modified then these values will be wrong.

What is the minimum data that needs to be saved to recreate the pane positioning?

Here is some code that gets around some of the save/load perspective problems.

void wxPositionChecker::LoadAui(wxAuiManager& manager, wxConfigBase& cfg, bool update)
{
wxAuiPaneInfoArray& panes = manager.GetAllPanes();
int nPanes = panes.GetCount();
for(int ct=0; ct<nPanes; ct++)
{
wxAuiPaneInfo& pane = panes[ct];
wxString paneData = cfg.Read(pane.name,_T(""));
if(!paneData.IsEmpty())
{
wxAuiPaneInfo tempPane;
manager.LoadPaneInfo(paneData, tempPane);
if (pane.IsOk())
{
tempPane.caption = pane.caption;
tempPane.best_size = pane.best_size;
tempPane.min_size = pane.min_size;
tempPane.max_size = pane.max_size;
pane.SafeSet(tempPane);
}
}
}
if(update)
{
manager.Update();
}
}

void wxPositionChecker::SaveAui(wxAuiManager& manager, wxConfigBase& cfg)
{
wxAuiPaneInfoArray& panes = manager.GetAllPanes();
int nPanes = panes.GetCount();
for(int ct=0; ct<nPanes; ct++)
{
wxAuiPaneInfo& pane = panes[ct];
cfg.Write(pane.name,manager.SavePaneInfo(pane));
}
}

Please don't take this as a rant agains wxAUI. This is a relatively minor issue to work around but I thought it would be a good idea to mention the problem.

Thanks,
Les
Les Newell
Registered User
 
Posts: 4
Joined: Fri Feb 16, 2007 5:52 am

Postby Huge on Sun Feb 18, 2007 7:00 pm

Yes, I agree with everything you say.
I'll be doing similar hacks to the code too - I think this should at least be an option on the main branch: LoadPerspective(IgnoreUnspecifiedPanes,DontBailOnMissingPane, PreserveBestSizeAndCaption).

Huge.
Huge
Registered User
 
Posts: 25
Joined: Thu Dec 28, 2006 1:12 am

Postby Ben on Tue Feb 20, 2007 9:58 am

Hi Les,

I, too, agree. LoadPerspective shouldn't bail out if a pane is missing. It should continue and try to finish up the job as best as it can.

Thanks for the report,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Return to wxAUI Questions, Thoughts & Feedback