rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.53k stars 106 forks source link

set-event fails sometimes #162

Closed mmontone closed 2 years ago

mmontone commented 2 years ago

Sometimes I get the following error:

The value
  NIL
is not of type
  HASH-TABLE
when binding HASH-TABLE
   [Condition of type TYPE-ERROR]

Restarts:
 0: [ABORT] abort thread (#<THREAD "CLOG event handler CLOG563726:click" RUNNING {1001A7A843}>)

Backtrace:
  0: (SB-KERNEL:%PUTHASH "CLOG564230:click" NIL #<FUNCTION (LAMBDA (CLOG::DATA) :IN CLOG:SET-ON-EVENT) {1005D56DCB}>) [external]
  1: ((:METHOD CLOG::SET-EVENT (CLOG:CLOG-OBJ T T)) #<CLOG:CLOG-ELEMENT {1005D54BB3}> "click" #<FUNCTION (LAMBDA (CLOG::DATA) :IN CLOG:SET-ON-EVENT) {1005D56DCB}> :CALL-BACK-SCRIPT "" :EVAL-SCRIPT "" :POST..
  2: ((SB-PCL::EMF CLOG::SET-EVENT) #<unused argument> #<unused argument> #<CLOG:CLOG-ELEMENT {1005D54BB3}> "click" #<FUNCTION (LAMBDA (CLOG::DATA) :IN CLOG:SET-ON-EVENT) {1005D56DCB}> :CANCEL-EVENT T :ONE..
  3: ((:METHOD CLOG:SET-ON-EVENT (CLOG:CLOG-OBJ T T)) #<CLOG:CLOG-ELEMENT {1005D54BB3}> "click" #<FUNCTION (LAMBDA (#:G23) :IN MOLD-DESKTOP/CLOG-GUI::CREATE-HALO-BUTTON) {543B542B}> :CANCEL-EVENT T :ONE-TI..
  4: ((SB-PCL::EMF CLOG:SET-ON-EVENT) #<unused argument> #<unused argument> #<CLOG:CLOG-ELEMENT {1005D54BB3}> "click" #<FUNCTION (LAMBDA (#:G23) :IN MOLD-DESKTOP/CLOG-GUI::CREATE-HALO-BUTTON) {543B542B}> :..

after trying to set-on-event after creating a clog-element with create-child.

Error occurs in set-event, when trying to set the handler: (setf (gethash hook (connection-data obj)) handler)

Have you encountered this before? Perhaps I'm doing something wrong ... I don't see these for all cases.

rabbibotton commented 2 years ago

One thought that comes to mind if you are using create-child is that perhaps the html you are passing to create-child has no outer tag and so no ID can be assigned to it to create a valid clog-element. (I will do some experiments)

Example "<p>hello</p><p>how are you?</p>" would be an issue. "<span><p>hello</p><p>how are you?</p></span>" would be ok.
rabbibotton commented 2 years ago

Well that thought doesn't seem to create a similar issue.. at least in a one off.

I have seen that error show up in the past on connection shutting down mid event. If you can give me a bigger snippet or something that recreates happy to flush out the error. In mean time will try and reproduce.

mmontone commented 2 years ago

Thanks. Don't worry about this. This probably some issue with my code. I was asking just in case. I'm closing for now and I'll report when I find something.

mmontone commented 2 years ago

I think where the problem is. The dom element I'm trying to attach to is not being properly created browser-side. Has to do with some library usage, etc.

rabbibotton commented 2 years ago

Either way I am going to handle this error more gracefully as can happen in a race condition between setting an event and a connection closing. Thanks!!!