# Graphical debugger does not work with XPCE applications

**URL:** <https://swi-prolog.discourse.group/t/graphical-debugger-does-not-work-with-xpce-applications/5387>\
**Category:** Help!\
**Tags:** bug\
**Created:** [May 11, 2022, 8:22am UTC](https://swi-prolog.discourse.group/t/graphical-debugger-does-not-work-with-xpce-applications/5387 "2022-05-11T08:22:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![duesentrieb17](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/duesentrieb17/32/4333_2.png) [@duesentrieb17](https://swi-prolog.discourse.group/u/duesentrieb17)\
**Post date:** [May 11, 2022, 8:22am UTC](https://swi-prolog.discourse.group/t/graphical-debugger-does-not-work-with-xpce-applications/5387/1 "2022-05-11T08:22:17Z")

</div>

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:

```prolog
:-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', []).

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 11, 2022, 9:00am UTC](https://swi-prolog.discourse.group/t/graphical-debugger-does-not-work-with-xpce-applications/5387/2 "2022-05-11T09:00:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![duesentrieb17](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/duesentrieb17/32/4333_2.png) [@duesentrieb17](https://swi-prolog.discourse.group/u/duesentrieb17)\
**Post date:** [May 11, 2022, 9:52am UTC](https://swi-prolog.discourse.group/t/graphical-debugger-does-not-work-with-xpce-applications/5387/3 "2022-05-11T09:52:39Z")

</div>

Now it works, thanks!
