summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/graphics/buffer.scm16
1 files changed, 9 insertions, 7 deletions
diff --git a/chickadee/graphics/buffer.scm b/chickadee/graphics/buffer.scm
index 40ebce8..8a30ea3 100644
--- a/chickadee/graphics/buffer.scm
+++ b/chickadee/graphics/buffer.scm
@@ -234,13 +234,15 @@ resized."
(let ((old-bv (buffer-data buffer)))
(set-buffer-length! buffer length)
(when old-bv
- (unmap-buffer! buffer)
- ;; TODO: Set map mode in record
- (map-buffer! buffer 'write-only)
- (let ((new-bv (buffer-data buffer)))
- (bytevector-copy! old-bv 0 new-bv 0
- (min (bytevector-length old-bv)
- (bytevector-length new-bv))))))
+ ;; Need to make a copy of the data.
+ (let ((old-bv (bytevector-copy old-bv)))
+ (unmap-buffer! buffer)
+ ;; TODO: Set map mode in record
+ (map-buffer! buffer 'write-only)
+ (let ((new-bv (buffer-data buffer)))
+ (bytevector-copy! old-bv 0 new-bv 0
+ (min (bytevector-length old-bv)
+ (bytevector-length new-bv)))))))
(error "cannot resize static buffer")))
(define-syntax-rule (with-mapped-buffer buffer body ...)