issue-#34 fixing the reuse of open documents

Post Reply
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

issue-#34 fixing the reuse of open documents

Post by Josef Templ »

This issue is about the reuse of open documents in BB.
When clicking on a link to a help text that is already open within BlackBox,
a new help text window is opened. This is in contrast to the expected behavior of
reusing the open window (bring to front) as it is done when editing documents.
The reason is a very unsystematic treatment of reuse of open documents in BB 1.6.
Related anomalies arise with other document modes (except edit mode)
and need to be taken into account when changing this behavior.
There are also cases with tool dialogs (if I remember correctly) where there is a wrong reuse if
the same window title is used for different documents. That's why I classified this issue as a bug.
A proposal for a much more systematic treatment of reuse of open documents based on
file name, location, converter and document flags instead of window titles is available in CPC 1.7 rc5.

Refers to CPC 1.7 rc5 change list item 9 and Open Points 05.

The diffs can be found in http://redmine.blackboxframework.org/pr ... d7f3a5a888.

- Josef
User avatar
DGDanforth
Posts: 1061
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA
Contact:

Re: issue-#34 fixing the reuse of open documents

Post by DGDanforth »

Josef,
Very nice. I agree with the needed change.
-Doug
Bernhard
Posts: 68
Joined: Tue Sep 17, 2013 6:56 am
Location: Munich, Germany

Re: issue-#34 fixing the reuse of open documents

Post by Bernhard »

yes, I like the solution too.
--
Bernhard
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#34 fixing the reuse of open documents

Post by Ivan Denisov »

I am suggesting to add one more line in OpenBrowser.
w.SetTitle(title$);

Code: Select all

Windows.dir.Select(w, Windows.lazy);
w.SetTitle(title$);
v := w.doc.ThisView();
I think, that it is good to change the title, because if developer call

Code: Select all

StdCmds.OpenBrowser('Tour.odc', 'test')
he is expecting that this window will have this title, not another.
He will be unable to close this window by title later, for example, if we do not add this line. So If we do not add this line we will break back compatibility.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#34 fixing the reuse of open documents

Post by Josef Templ »

> I am suggesting to add one more line in OpenBrowser.
> w.SetTitle(title$);

Hmmm...
Normally, the new and the old title will be the same,
so it does not make a difference how to handle the change.
If the title changes, it is the question if we should reuse at all.

If "close by title" (I don't know what this means) is important, the
missing old title may be a problem as well as the missing new title.

- Josef
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#34 fixing the reuse of open documents

Post by Ivan Denisov »

I agree, that if the title is differ, better to run default behaviour. If them are the same you suggested behaviour is very good.

"Close by title" means to filter all windows and close if the names are matching.

I am using such code:

Code: Select all

	PROCEDURE GetWindow (name: ARRAY OF CHAR): Windows.Window;
		VAR win, winTmp: Windows.Window; title: Views.Title;
	BEGIN
		win := Windows.dir.First();
		winTmp := NIL;
		WHILE (win # NIL) & (winTmp = NIL) DO
			win.GetTitle(title);
			IF title$ = name$ THEN
				winTmp := win
			END;
			win := Windows.dir.Next(win)
		END;
		RETURN winTmp
	END GetWindow;
	
	PROCEDURE Close* (name: ARRAY OF CHAR);
		VAR win: Windows.Window;
	BEGIN
		ASSERT(name$ # "", 20);
		win := GetWindow(name);
		IF win # NIL THEN
			Windows.dir.Select(win, FALSE);
			Windows.dir.Close(win)
		END
	END Close;
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#34 fixing the reuse of open documents

Post by Josef Templ »

I have now added a title check when reusing a (Browser) window.
Reuse happens only if the title is the same (in addition to the other rules as already checked).
For the cases where there is no title available, an empty title is used, which signals that
there should be no title check in Windows.GetBySpec.

I think the issue is in a good shape now and ready for voting.

- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#34 fixing the reuse of open documents

Post by Josef Templ »

The title check did not work as expected.
I had to revert this part of the changes of issue-#34.
Let me know if anybody has an idea how to solve it.

- Josef
Post Reply