-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to create Modal from Task callback #137
Comments
What happens if you keep a reference to the modal? It’s probably getting released. |
By keeping a reference, do you mean to replace the callback function with something similar to the following block? Phoenix.log r.output
sf = Space.active().screen().frame()
status = Modal.build
text: r.output
duration: p.modals.duration
weight: p.modals.weight
appearance: p.modals.appearance
origin: (mf) ->
x: sf.x + sf.width / 2 - mf.width / 2
y: sf.y + sf.height / 2 - mf.height / 2
status.show() With this callback, the same results are observed. |
I also tried instantiating the modal from outside of the callback, and instead setting the text and showing the modal in the callback, with the same results: sf = Space.active().screen().frame()
status = Modal.build
duration: p.modals.duration
weight: p.modals.weight
appearance: p.modals.appearance
origin: (mf) ->
x: sf.x + sf.width / 2 - mf.width / 2
y: sf.y + sf.height / 2 - mf.height / 2
Task.run '/bin/sh', [
"-c", "date"
], (r) ->
Phoenix.log r.output
status.text = r.output
status.show() EDIT: I forgot to mention, |
@metakirby5 Ok, thanks! I’ll look into this. I wonder why (or if) this only happens with Task callbacks. |
Seems like Task.run '/bin/sh', [
"-c", "date"
], (r) ->
Phoenix.log '1'
Timer.after 0, -> Phoenix.log '2'
Timer.after 0, -> Phoenix.log '3' I get:
|
@metakirby5 Very intriguing, thanks for the information! I started a new job, so it will take me a bit longer to sort these, but hopefully very soon. Sorry for the wait! |
By the way, have you tried testing this with an unmanaged |
@kasper Same symptoms, unfortunately :( mytask = new Task '/bin/sh', [
"-c", "date"
], (r) ->
Phoenix.log '1'
Timer.after 0, -> Phoenix.log '2'
Timer.after 0, -> Phoenix.log '3' Tested it with the Modal as well, but you can probably tell how the code for that looks. Also, no worries about the delay! I found Phoenix.notify (which still works) to be a reasonable alternative for the time being. Good luck on the new job :) |
@metakirby5 Found the cause, which is pretty obvious from the stack trace. Since tasks are now run asynchronously, the callback is getting called from another thread which causes issues. You can among other things only update the UI from the main thread. |
Fixed in master. Sorry for the wait! |
I tried to use
Task.run
to start a task that launches a modal with output from a shell command in CoffeeScript, as follows:The modal does not show up. However, the output is logged by the Phoenix.log call, indicating that the callback did not fail. Additionally, I verified that the
Modal.build
would not have failed under normal circumstances by un-indenting the relevant lines.I get a lot of similar looking messages in Console, the last of which is:
Let me know if you need the full output -- it's a bit long.
The text was updated successfully, but these errors were encountered: