HiTECNOLOGYs / cl-charms

More up-to-date version of cl-charms. Forked it because it was, apparently, abandoned by author and I couldn't contact him.
https://gitorious.org/cl-charms
Other
155 stars 29 forks source link

Window dimensions aren't updated properly #28

Closed MatthewRock closed 8 years ago

MatthewRock commented 8 years ago

This code snippet is the smallest isolated case of bug I can find:


(defun test ()
  (charms:with-curses ()
    (multiple-value-bind (width height) (charms:window-dimensions cl-charms:*standard-window*)
      (print (list width height)))))

Bug description: The bug prevents window dimensions from being updated properly - it prints dimensions from previous window.

Steps to reproduce:

  1. Open a window with sbcl compiler.
  2. run #'test
  3. After test finishes its execution, resize the window.
  4. Run test again.
  5. After test finishes its execution, run test again.

Result: (proper-x proper-y) (old-x old-y) (proper-x proper-y)

Expected: (proper-x proper-y) x 3

I'm running SBCL 1.3.4 with cl-charms-20160318-git, downloaded with quicklisp.

MatthewRock commented 8 years ago

I've poked around the code, but I have no idea what's wrong. I've tried changing the #'standard-window closure by creating a function that resets %cached-window, then change #'finalize so that each time my program ends, the %cached-window gets rebound, but this didn't solve the problem. Same with using (gc) in between the calls to #'test. Moreover, the program looks similarly to what I've got in C. Any ideas?

glider-gun commented 8 years ago

Probably you should refresh window before retrieving width/height like:

(defun test ()
  (charms:with-curses ()
    (charms:refresh-window cl-charms:*standard-window*)
    (multiple-value-bind (width height) (charms:window-dimensions cl-charms:*standard-window*)
      (sleep 3)
      (print (list width height)))))
stylewarning commented 8 years ago

Fixed by @MatthewRock in 06859f597189f36bf0ebc6acadddf2247c0234f6