Ticket #446 (closed defect: fixed)

Opened 21 months ago

Last modified 21 months ago

Crashes when using text-fields without label

Reported by: mimmottos@… Owned by: williams
Priority: major Milestone:
Component: williams/table-panel.plt Keywords:
Cc: Version: (1 1)
Racket Version: [3m].


The following code crashes:

#lang racket/gui


;(require (planet williams/table-panel/table-panel))
(require "table-panel.ss")

;; The top-level frame
(define frame

(instantiate frame%

("Editor Grid")))

;; The table panel
(define table-panel

(instantiate table-panel%

(alignment '(center center))
(dimensions '(2 1))))

;; Now lets populate it
(for ((i (in-range 2)))

(let* ((rows (if (zero? i) 5 1))

(cols 2)
(child (instantiate table-panel%

(style '(border))
(dimensions (list rows cols))
(column-stretchability #t)
(row-stretchability #f))))

(for* ((k (in-range rows))

(j (in-range cols)))

;(printf "k,j: ~a,~a~n" k j)
(if (zero? i)

(new text-field%

;((format "~a ~a" k j) child)
(parent child)
;(label "ab")
(label #f)
(stretchable-width #t)
(stretchable-height #f)

(lambda (tf event)

(printf "~a~n" (send tf get-value)))))

(instantiate button%

((format "Button ~a" j) child)
(stretchable-width #t)
(stretchable-height #f)

(lambda (button event)

(printf "You clicked button ~a~n" (send button get-label)))))))))

; Show the top-level frame.
(send frame show #t)
The cause of the error is division by zero when calculating ratio in (on or near line 280):


(lambda (i stretchable? width)

(when stretchable?

(let* ((ratio (/ width total-column-stretchable-width))

(quota (round (* ratio delta-width))))

(vector-set! column-widths i

(+ (vector-ref column-widths i) quota))

(set! total-column-stretchable-width

(- total-column-stretchable-width width))

(set! delta-width (- delta-width quota)))))

column-stretchabilities? column-widths)

If I replace the line:

(when stretchable?

with the line:

(when (and stretchable? (positive? total-column-stretchable-width))

at least my code starts to do what I expected. Still I'm not sure whether this is the right way to handle the crash since I'm a Racket novice and thus can't claim to understand your code completely.

Jussi Salmela

Change History

Changed 21 months ago by williams

  • status changed from new to closed
  • resolution set to fixed

The problem was that because of rounding, we could run out of available expansion space when stretching widgets. This has been fixed and a new version (1.2) pushed to PLaneT.

Note: See TracTickets for help on using tickets.