issue-#106 View restored twice on Open

Re: issue-#106 View restored twice on Open

Postby DGDanforth » Wed Oct 11, 2017 8:10 pm

Robert,
I have implemented your fixups and for 4 modules they seem to work correctly (only one call to my draw routines).
I'll continue using this and will let you know if any problems arise.
Thank you.
-Doug
User avatar
DGDanforth
 
Posts: 1034
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA

Re: issue-#106 View restored twice on Open

Postby Robert » Mon Oct 16, 2017 11:02 am

I am assuming that Doug is still finding this fixup helpful ...

I think that this issue should be closed (rejected) as a bug. It seems to be the case that some Views do require both Restores. It looks like (this comment includes a lot of guesswork) TextViews use their first Restore to decide what to do with their scroll bars, and only on the second, and subsequent, Restores do their Setters make all the correct decisions.

The fixup could be made a permanent feature which would benefit Views that are simple (in the sense that they immediately know how to Restore themselves), but complex in the sense that each Restore is time consuming. If it were to be a permanent feature I would stay with essentially the same idea, but change the implementation in detail. Specifically, instead of having a read only INTEGER variable src in HostWindows, I would have a read/write BOOLEAN variable in Views, maybe called initialRestore.

What do other people think?
User avatar
Robert
 
Posts: 797
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#106 View restored twice on Open

Postby Josef Templ » Wed Oct 18, 2017 5:12 am

Since I still don't see any other solution to this problem I would agree to add Robert's
'work-around' to 1.7.1 and then close this issue.

I would leave it as a global variable in HostWindows for now.
Is the name of that variable ("src") the best one?
It is basically a BOOLEAN indicating that Restore can be skipped because it is called from CreateDoc.
VAR createDoc: BOOLEAN;
A comment should of course be added to the global variable.

Note: I see this as a work-around, not a final solution. It is possible that somebody with more knowledge about the
steps involved when opening a document can provide a better solution in the future but this can be far away.
The nice thing about this work-around is that it cannot do any harm to existing views.

- Josef
Josef Templ
 
Posts: 1714
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#106 View restored twice on Open

Postby DGDanforth » Wed Oct 18, 2017 5:18 am

Josef Templ wrote:VAR createDoc: BOOLEAN;
A comment should of course be added to the global variable.
- Josef

Perhaps
Code: Select all
VAR docCreated: BOOLEAN;

would be better since the user wants to know the status.
-Doug
User avatar
DGDanforth
 
Posts: 1034
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA

Re: issue-#106 View restored twice on Open

Postby Josef Templ » Wed Oct 18, 2017 8:17 am

Doug, does that mean that docCreated is set to FALSE initially (before the Restore is called) and
set to TRUE at the end of CreateDoc (after the Restore is called)?
The code in your Restore method would then be something like:

Code: Select all
IF HostWindows.docCreated THEN ... (* draw view only once *)
(* ELSE skip redundant drawing *)
END


- Josef
Josef Templ
 
Posts: 1714
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#106 View restored twice on Open

Postby DGDanforth » Wed Oct 18, 2017 8:40 am

Josef Templ wrote:Doug, does that mean that docCreated is set to FALSE initially (before the Restore is called) and
set to TRUE at the end of CreateDoc (after the Restore is called)?
The code in your Restore method would then be something like:

Code: Select all
IF HostWindows.docCreated THEN ... (* draw view only once *)
(* ELSE skip redundant drawing *)
END


- Josef

I believe so, yes.
User avatar
DGDanforth
 
Posts: 1034
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA

Re: issue-#106 View restored twice on Open

Postby Robert » Wed Oct 18, 2017 5:58 pm

Josef Templ wrote:A comment should of course be added to the global variable.
Not required if it is adequately documented, which it must be.
I would put it in Views for two reasons:
1 - Views has a Docu file, HostWindows does not (or only an empty one!).
2 - Client code has to IMPORT Views anyway, requiring it to also import HostWindows is undesirable.
Putting it in Views means it has to be Read/Write, which is not so nice, but does not represent a real problem.

DGDanforth wrote:
Code: Select all
VAR docCreated: BOOLEAN;
would be better since the user wants to know the status.

I agree. But it needs an "*".
User avatar
Robert
 
Posts: 797
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#106 View restored twice on Open

Postby Josef Templ » Wed Oct 18, 2017 9:36 pm

Robert wrote:
Josef Templ wrote:A comment should of course be added to the global variable.
Not required if it is adequately documented, which it must be.
I would put it in Views for two reasons:
1 - Views has a Docu file, HostWindows does not (or only an empty one!).
2 - Client code has to IMPORT Views anyway, requiring it to also import HostWindows is undesirable.
Putting it in Views means it has to be Read/Write, which is not so nice, but does not represent a real problem.


If you put it in Views and document it hen you have the obligation to keep this stable.
But this is a (temporary) work-around for a problem that we don't understand yet.
This is not a solution and it should not be documented.

- Josef
Josef Templ
 
Posts: 1714
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#106 View restored twice on Open

Postby DGDanforth » Thu Oct 19, 2017 12:58 am

Robert wrote:
Josef Templ wrote:A comment should of course be added to the global variable.
Not required if it is adequately documented, which it must be.
I would put it in Views for two reasons:
1 - Views has a Docu file, HostWindows does not (or only an empty one!).
2 - Client code has to IMPORT Views anyway, requiring it to also import HostWindows is undesirable.
Putting it in Views means it has to be Read/Write, which is not so nice, but does not represent a real problem.

DGDanforth wrote:
Code: Select all
VAR docCreated: BOOLEAN;
would be better since the user wants to know the status.

I agree. But it needs an "*".


Also, most of my "Windows" are just views that do not refer to any document. Hence Views is the appropriate place
to put it.
User avatar
DGDanforth
 
Posts: 1034
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA

Re: issue-#106 View restored twice on Open

Postby Josef Templ » Thu Oct 19, 2017 9:08 am

DGDanforth wrote:Also, most of my "Windows" are just views that do not refer to any document. Hence Views is the appropriate place
to put it.


I am confused now.
The work-around from Robert was OK for me, for Robert and for you, Doug.
I was only talking about the naming and possibly the type of the introduced auxiliary variable
with the intention to make it better understandable what happens here.
Since this work-around worked for you, Doug, I was considering to put it into 1.7.1,
as a work-around until a better solution is found.
This saves you to do this adaptation in your private installation.

By moving this "smart hack" into Views and documenting it we glorify the work-around but
there is still no solution to the underlying problem. Actually it makes it more difficult to solve it later
because of possible incompatibilities with the documented work-around.
IMHO, importing from HostWindows is the correct way of expressing this dependency on a
temporary smart low-level hack. Saving this import is kind of a fake.

- Josef
Josef Templ
 
Posts: 1714
Joined: Tue Sep 17, 2013 6:50 am

PreviousNext

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron