Page 1 of 1

issue-#34 fixing the reuse of open documents

Posted: Thu Mar 26, 2015 2:27 pm
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

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

Posted: Sat Mar 28, 2015 12:10 am
by DGDanforth
Josef,
Very nice. I agree with the needed change.
-Doug

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

Posted: Sat Mar 28, 2015 9:28 am
by Bernhard
yes, I like the solution too.
--
Bernhard

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

Posted: Sat Mar 28, 2015 10:55 am
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.

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

Posted: Sun Mar 29, 2015 8:10 am
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

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

Posted: Sun Mar 29, 2015 9:41 am
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;

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

Posted: Mon Mar 30, 2015 4:37 pm
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

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

Posted: Wed Apr 29, 2015 7:55 am
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