gi-gtk-declarative
gi-gtk-declarative copied to clipboard
No window appears when running App.Simple application executable
I have created a standalone application based on GI.Gtk.Declarative.App.Simple
. Its sources are copy paste of the Hello.hs example.
You can find the repository here.
I observe the following:
- Trying to build and run it produces no window at all
$ stack build && stack exec amfora-hs
# No window, have to interrupt
^C^C
$
- Trying to load it inside
stack ghci
and runningmain
manually somehow does produce a window (greeting names cycle, all's working), but then there's another problem: when I click onx
(close) button, the application hangs withx
pressed down. Inghci
I can see thatmain
has returned, but window stays on screen
To be sure that all this is something related to gi-gtk-declarative
, I tried to replace main
contents with some simple hello-world window from haskell-gi
samples and it does work both with stack exec
and stack ghci
: window is shown and closed.
I'm not sure why no window appears for the case 1.
, but as for window freeze I suspect that this might have to do with the fact that there's no listener to window #destroy
event in App.Simple
code, but I might be mistaken.
Stack version: 1.9.3
Resolver: lts-13.2
(ghc version 8.6.3
)
gi-gtk-declarative: 0.4.1
gi-gtk-declarative-app-simple: 0.4.0
Make sure you comple with -threaded.
@owickstrom this is definitely something which could be better documented.
For the first case, as @aristaeus says, you need to add the -threaded GHC option.
For the second, I think you're right about the missing destroy listener. See the examples on how it's done there, with a special event for window being closed, eventually leading to Exit
.
The hint to use -threaded
helped to fix the first issue, thank you!
As for the second one in my project I actually use the example copy-pasted from this repo and it does have the special event for window closing which you mention, as you can see here, but the issue is still there.
When I said that there's no listener for #destroy
I've meant not the client code, but library code, this is the event used in haskell-gi
example, but not emitted by App.Simple
internally (not sure if needed, just an observation).
Did you try to run Hello
example from stack ghci
, does it close normally for you? I didn't try to compile this repo on my machine, will try soon. If this only happens in my sample-project repository, but not in gtk-gi-declarative
repo, must be some local issue...
Oh, okay. Sorry I'm on vacation and I don't have a laptop. Let me try this with ghci next week, and I'll get back to you.
Den ons 23 jan. 2019 19:14 skrev dimsuz [email protected]:
The hint to use -threaded helped to fix the first issue, thank you!
As for the second one in my project I actually use the example copy-pasted from this repo and it does have the special event for window closing which you mention, as you can see here https://github.com/dimsuz/amfora-hs/blob/master/src/Main.hs#L26, but the issue is still there.
When I said that there's no listener for #destroy I've meant not the client code, but library code, this is the event used in haskell-gi example, but not emitted by App.Simple internally (not sure if needed, just an observation).
Did you try to run Hello example from stack ghci, does it close normally for you? I didn't try to compile this repo on my machine, will try soon. If this only happens in my sample-project repository, but not in gtk-gi-declarative repo, must be some local issue...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/owickstrom/gi-gtk-declarative/issues/38#issuecomment-456929759, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZYCL99ym_Ck-5pqhNWBqjOvyw3IQeQks5vGLStgaJpZM4Z9U_N .
Thanks, I'll report back if I find something interesting too. Have a good vacation! :)
OK, I can reproduce this in GHCi (and cabal v2-repl
) locally on the Hello
example. Haven't had time to dig into it yet, but I'll have a closer look this weekend hopefully.
I poked around a bit trying to fix the hang on exit in ghci
and while I didn't fix it I discovered some things worth noting.
-
I have a workaround that makes the X button work again. Namely just replace
True
toFalse
here: https://github.com/owickstrom/gi-gtk-declarative/blob/master/examples/AddBoxes.hs#L30. As I understand this lets the destroy signal propagate to the window. That makes me wonder if the topmost widget doesn't need to be explicitly destroyed. -
The builder example from
haskell-gi
also hangs on exit inghci
: https://github.com/haskell-gi/haskell-gi/blob/master/examples/introductory/src/builder.hs Again, it seems that callingGtk.mainQuit
is not enough inghci
. Modifying the example to send a close signal to the window on button click made the example work for me. -
The root cause is probably different, I suspect that some finalizers are not getting called or get called in a wrong thread. I base that on the investigation from https://github.com/haskell-gi/haskell-gi/issues/96, but that's only a weak suspicion.
My GHC version: 8.6.5
I ran into the exact same problem and the s/True/False/
workaround worked for me as well :+1:
Switching the propagation, if I'm not mistaken (it's been a while since I hacked on this), has the unfortunate effect of the special Exit
event not being emitted. Maybe this would not matter for most applications, but I think a graceful shutdown mechanism should depend on the Exit
event.
I've also confirmed it hangs in GHCi for me. Can't say say for certain, but I think it has worked before (maybe an older GHCi or haskell-gi package version).