← Back to team overview

kicad-developers team mailing list archive

Re: Ugly hack in LIB_VIEW_FRAME

 

Le 17/07/2017 à 22:38, Chris Pavlina a écrit :
> On Mon, Jul 17, 2017 at 04:29:44PM -0400, Wayne Stambaugh wrote:
>> On 7/17/2017 4:15 PM, Chris Pavlina wrote:
>>> The following is in LIB_VIEW_FRAME (viewlib_frame.h specifically):
>>>
>>>     // TODO(hzeller): looks like these members were chosen to be static to survive different
>>>     // instances of this browser and communicate it to the next instance. This looks like an
>>>     // ugly hack, and should be solved differently.
>>>     static wxString m_libraryName;
>>>
>>>     static wxString m_entryName;
>>>
>>> Is this a feature anyone needs? I can't see why the browser has to
>>> remember its list selection across instances. Will anyone miss this if I
>>> just make them non-static?
>>>
>>
>> Given that the kiface does not actually destroy the library viewer top
>> level window but rather hides it,
> 
> I am not so sure about this. If I set a breakpoint on the constructor,
> it fires every time I call up the dialog. It looks like there may be an
> unnecessary call to Destroy(), I'll look into that.

Library viewers can be run in normal mode or modal mode.

modal mode is used to select a symbol (or a footprint).
Therefore, in modal mode, viewer are destroyed on close.
If a viewer runs in normal mode (in fact quasimodal mode), and it is called to select a symbol, the
normal mode is destroyed.

I am not sure it is possible to switch between modes without destroying the frame.
Especially in modal mode, the wxFRAME_FLOAT_ON_PARENT style is used, and it imply the right parent
is set, and a specific event loop.

I am not sure changing event loop, style and parent of an existing wxFrame is easy and works fine.

But what is the actual problem with static members?
They are used in all dialogs to store last size, position, choice... during the session.

> 
>> defining these variables normally
>> shouldn't make any difference in the behavior.  I believe this behavior
>> goes back to the pre-kiface days when closing the library viewer would
>> actually destroyed the viewer top level window.  I like the fact that
>> the viewer comes back to the same point as I left it.  One thing you
>> might want to do if you change this is confirm that the behavior of the
>> viewer in the stand alone mode is the same as the single app mode.  It
>> should be but there are some subtle differences when running apps in the
>> stand alone mode versus the single app mode.

I also like that behavior.


-- 
Jean-Pierre CHARRAS


References