[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-guile-ncurses] Segmentation violations in menus
From: |
John Darrington |
Subject: |
[Bug-guile-ncurses] Segmentation violations in menus |
Date: |
Tue, 3 May 2016 13:17:45 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
The following (relatively simple) program, crashes at regular intervals, due to
incorrect
garbage collection. Patches to follow.
(use-modules (srfi srfi-1)
(ncurses curses)
(ncurses menu))
(define (do-my-thing menu)
(let ((ci (current-item menu)))
(addstr stdscr (format #f "This is item description: ~A" (item-description
ci))
#:y (- (lines) 2) #:x (- (cols) 2)))
)
(define (labels x l)
(if (> (length l) 1000)
l
(labels x (cons (format #f "~A~A" x (- 1000 (length l))) l))))
(define stdscr (initscr))
(cbreak!)
(noecho!)
(keypad! stdscr #t)
(let* (;; Labels for the menu items
(names (labels "Choice" '()))
(descriptions (labels "Description " '()))
;; Create menu items for each label
(my-items (map (lambda (name desc) (new-item name desc))
names
descriptions))
;; Create the menu
(my-menu (new-menu my-items))
)
;; Draw the menu
(move stdscr (- (lines) 2) 0)
(addstr stdscr "Press 'q' to Quit")
(post-menu my-menu)
(refresh stdscr)
(let loop ((c (getch stdscr)))
(cond
((eqv? c KEY_DOWN)
(begin
(menu-driver my-menu REQ_DOWN_ITEM)
(do-my-thing my-menu)
(loop (getch stdscr))))
((eqv? c KEY_UP)
(begin
(menu-driver my-menu REQ_UP_ITEM)
(do-my-thing my-menu)
(loop (getch stdscr))))
((eqv? c KEY_NPAGE)
(begin
(gc)
(menu-driver my-menu REQ_SCR_DPAGE)
(do-my-thing my-menu)
(loop (getch stdscr))))
((eqv? c KEY_PPAGE)
(begin
(gc)
(menu-driver my-menu REQ_SCR_UPAGE)
(do-my-thing my-menu)
(loop (getch stdscr))))
((eqv? c KEY_HOME)
(begin
(gc)
(menu-driver my-menu REQ_FIRST_ITEM)
(do-my-thing my-menu)
(loop (getch stdscr))))
((eqv? c KEY_END)
(begin
(gc)
(menu-driver my-menu REQ_LAST_ITEM)
(do-my-thing my-menu)
(loop (getch stdscr))))
;; If 'Q' or 'q' is pressed, quit. Otherwise, loop.
((not (or (eqv? c #\Q) (eqv? c #\q)))
(loop (getch stdscr)))))
(endwin))
--
Avoid eavesdropping. Send strong encryted email.
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.
signature.asc
Description: Digital signature
- [Bug-guile-ncurses] Segmentation violations in menus,
John Darrington <=
- [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs, John Darrington, 2016/05/03
- Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs, John Darrington, 2016/05/03
- Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs, Mike Gran, 2016/05/03
- Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs, John Darrington, 2016/05/03
- Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs, Mike Gran, 2016/05/26
- Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs, John Darrington, 2016/05/26
- Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs, Mike Gran, 2016/05/26
[Bug-guile-ncurses] [PATCH 2/2] Do not allow menu's internal data to be destroyed, until the menu itself is destroyed., John Darrington, 2016/05/03