Graphical debugger does not work with XPCE applications

I’m using: SWI-Prolog version 8.4.2, Windows 10

I want the code to:
stop behind the gtrace with the debugger window showing the source code

But what I’m getting is:
the debugger window opens without content and the hourglass is displayed (for ever).
Good old 5.9.7 works as expected.

My code looks like this:

:-use_module([library(pce)]).
test :-
  new(ViewR, view(view, size(120, 30))),
  send(ViewR, open),
  gtrace,
  format(user_error, 'this line should be displayed in the debugger window', []).

AFAIK this is caused by xpce by default running in a separate thread, such that the development tools runs asynchronously from your application. xpce isn’t good with threads, so if you want to develop xpce applications you better disable running xpce in a thread. To do so, run

:- set_prolog_flag(xpce_threaded, false).

before loading library(pce) or using anything that uses xpce, such as any of the development tools.

Once your application works as expected you can re-enable xpce threading and start the application using in_pce_thread/1. On the other hand, there is not much point in running xpce in a thread if the whole purpose of the application is the graphics.

1 Like

Now it works, thanks!