Based on the discussion starting in viewtopic.php?f=50&t=385&start=80#p6578 I have created issue-#181 https://redmine.blackboxframework.org/issues/181.
An experimental version is committed in http://blackboxframework.org/unstable/i ... c1.985.zip.
See diffs at https://redmine.blackboxframework.org/p ... 39ecd38fe0.
I have done the following changes:
1. I added error messages in the form of a Windows message box for the most common types of errors.
Note: Everything inside HostDialog.OpenExternal runs in a separate thread. Care must be taken not to use the BlackBox runtime system, in particular the heap.
2. Under wine I first try the wine associations and if that fails with any kind of association error I retry with 'winebrowser ' prepended.
If that also fails, the error message refers to the original wine association.
3. I added Host/Rsrc/Strings resources for the error messages.
- Josef
issue-#181 fixing error handling of HostDialog.OpenExternal
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#181 fixing error handling of HostDialog.OpenExter
Error message as modal dialog is not a good idea. That stops the BlackBox program until OK is clicked. Better is to write the message into the Log windows and BlackBox continues.
- Helmut
- Helmut
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#181 fixing error handling of HostDialog.OpenExter
This is what I also expected. But what I have seen in my experiments is that a modal dialog does not stop BlackBox.Zinn wrote:Error message as modal dialog is not a good idea. That stops the BlackBox program until OK is clicked. Better is to write the message into the Log windows and BlackBox continues.
- Helmut
It only blocks the delivery of mouse and keyboard messages but actions continue to run.
Note: The special problem to consider here is that the error message is produced by a parallel thread.
Any interaction with the main thread must be avoided because BlackBox is single-threaded.
- Josef
Re: issue-#181 fixing error handling of HostDialog.OpenExter
I observe that my sample
(!)"Dialog.OpenExternal('Test/Docu/Buch2.pdf')"
reports the correct error message: File 'Test/Docu/Buch2.pdf' not found.
and the sample
(!)"Dialog.OpenExternal('Test/Docu/Buch.pdf')"
opens correctly the pdf file.
It is a big improvement.
That is the result in Wine.
In Windows the second sample produce the error message File 'Test/Docu/Buch.pdf' not found.
There I have to enter the absolut path otherwise file is not found.
A solution may be insert before the Wine test:
IF res = WinApi.SE_ERR_FNF THEN
(* Open failed use absolute filename and try again - Windows only *)
res := WinApi.GetFullPathNameW(fileName, LEN(wine_fileName), wine_fileName, np);
res := WinApi.ShellExecuteW(0, NIL, wine_fileName, NIL, NIL, WinApi.SW_SHOWNORMAL);
END;
- Helmut
(!)"Dialog.OpenExternal('Test/Docu/Buch2.pdf')"
reports the correct error message: File 'Test/Docu/Buch2.pdf' not found.
and the sample
(!)"Dialog.OpenExternal('Test/Docu/Buch.pdf')"
opens correctly the pdf file.
It is a big improvement.
That is the result in Wine.
In Windows the second sample produce the error message File 'Test/Docu/Buch.pdf' not found.
There I have to enter the absolut path otherwise file is not found.
A solution may be insert before the Wine test:
IF res = WinApi.SE_ERR_FNF THEN
(* Open failed use absolute filename and try again - Windows only *)
res := WinApi.GetFullPathNameW(fileName, LEN(wine_fileName), wine_fileName, np);
res := WinApi.ShellExecuteW(0, NIL, wine_fileName, NIL, NIL, WinApi.SW_SHOWNORMAL);
END;
- Helmut
Re: issue-#181 fixing error handling of HostDialog.OpenExter
Now we have nice error reporting in Dialog.OpenExternal.
The same is missing in Dialog.RunExternal, e.g.
(!)"Dialog.RunExternal('notepad.exe')"
opens the notepad.
(!)"Dialog.RunExternal('notepad2.exe')"
nothing happens even no error messages.
- Helmut
The same is missing in Dialog.RunExternal, e.g.
(!)"Dialog.RunExternal('notepad.exe')"
opens the notepad.
(!)"Dialog.RunExternal('notepad2.exe')"
nothing happens even no error messages.
- Helmut
Re: issue-#181 fixing error handling of HostDialog.OpenExter
Occasionally we need in Dialog.OpenExternal
wine_fileName := "winebrowser " + fileName$;
instead of fileName only.
The same situation we have in Dialog.RunExternal. There we need occasionally
wine_exeName := "wineconsole " + exeName$;
instead of exeName only.
E.g. we need wineconsole
(!)"Dialog.RunExternal('cmd')"
(!)"Dialog.RunExternal('cmd /k dir')"
E.g. works without wineconsole
(!)"Dialog.RunExternal('cmd /k regedit')"
(!)"Dialog.RunExternal('cmd /c start /unix /usr/bin/gedit')"
- Helmut
wine_fileName := "winebrowser " + fileName$;
instead of fileName only.
The same situation we have in Dialog.RunExternal. There we need occasionally
wine_exeName := "wineconsole " + exeName$;
instead of exeName only.
E.g. we need wineconsole
(!)"Dialog.RunExternal('cmd')"
(!)"Dialog.RunExternal('cmd /k dir')"
E.g. works without wineconsole
(!)"Dialog.RunExternal('cmd /k regedit')"
(!)"Dialog.RunExternal('cmd /c start /unix /usr/bin/gedit')"
- Helmut
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#181 fixing error handling of HostDialog.OpenExter
>> (!)"Dialog.OpenExternal('Test/Docu/Buch.pdf')"Zinn wrote:Occasionally we need in Dialog.OpenExternal
wine_fileName := "winebrowser " + fileName$;
instead of fileName only.
The same situation we have in Dialog.RunExternal. There we need occasionally
wine_exeName := "wineconsole " + exeName$;
instead of exeName only.
E.g. we need wineconsole
(!)"Dialog.RunExternal('cmd')"
(!)"Dialog.RunExternal('cmd /k dir')"
E.g. works without wineconsole
(!)"Dialog.RunExternal('cmd /k regedit')"
(!)"Dialog.RunExternal('cmd /c start /unix /usr/bin/gedit')"
- Helmut
You have to use \ under Windows, I think.
Sometimes / is also supported but I don't know the rule behind it.
wine will probably support both.
RunExternal can of course also be improved but let us focus on OpenExternal first.
What do you mean by "Occasionally"? Can you give a rule?
- Josef
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#181 fixing error handling of HostDialog.OpenExter
There seems to be a real wine bug with the implementation of "cmd".
Unfortunately there is no error code returned for the failing examples so it is not easily possible to
retry with wineconsole prepended.
The bug is not easy to see but I think I know it.
It is possible to prepend "wineconsole " explicitly in the RunExternal command.
If it is considered important to be portable, it is possible to detect the special command start "cmd " and prepend "wineconsole " only for that special pattern.
I don't know how important it is to be portable in this case.
- Josef
Unfortunately there is no error code returned for the failing examples so it is not easily possible to
retry with wineconsole prepended.
The bug is not easy to see but I think I know it.
It is possible to prepend "wineconsole " explicitly in the RunExternal command.
If it is considered important to be portable, it is possible to detect the special command start "cmd " and prepend "wineconsole " only for that special pattern.
I don't know how important it is to be portable in this case.
- Josef
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#181 fixing error handling of HostDialog.OpenExter
I have now added some error messages also for RunExternal.
In addition, I have added a work-around a bug in wine when calling 'cmd'.
In this case, 'wineconsole ' is prepended.
The diffs are https://redmine.blackboxframework.org/p ... a6bdc37419.
For testing please use http://blackboxframework.org/unstable/i ... c1.988.zip.
- Josef
In addition, I have added a work-around a bug in wine when calling 'cmd'.
In this case, 'wineconsole ' is prepended.
The diffs are https://redmine.blackboxframework.org/p ... a6bdc37419.
For testing please use http://blackboxframework.org/unstable/i ... c1.988.zip.
- Josef
Re: issue-#181 fixing error handling of HostDialog.OpenExter
Now the implementation of OpenExternal & RunExternal is much better.
Josef improved
- the error handling
- solved the winebrowser problem
- added wineconsole
But there are still some differences to the CPC edition. Would you like to know?
One differences is that windows need absolute path name for OpenExternal and does not open a file with relative path name (file not found).
This I already reported above. It doesn’t matter if you use ‘/’ or ‘\’ the behaviour is the same.
- Helmut
Josef improved
- the error handling
- solved the winebrowser problem
- added wineconsole
But there are still some differences to the CPC edition. Would you like to know?
One differences is that windows need absolute path name for OpenExternal and does not open a file with relative path name (file not found).
This I already reported above. It doesn’t matter if you use ‘/’ or ‘\’ the behaviour is the same.
- Helmut