Fixed gtk-object-destroy-callback for <text-widget>s.
authorMatt Birkholz <matt@birkholz.chandler.az.us>
Tue, 20 Sep 2011 02:53:24 +0000 (19:53 -0700)
committerMatt Birkholz <matt@birkholz.chandler.az.us>
Tue, 20 Sep 2011 02:53:24 +0000 (19:53 -0700)
src/gtk-screen/gtk-screen.pkg
src/gtk-screen/gtk-screen.scm

index fe9a01aafa3902d00e70d55cf32c5cdbf4350b66..4e33dbc8a23af4a3a35704f04c88e6ef78a289d0 100644 (file)
@@ -179,7 +179,7 @@ USA.
          fix-ink-widgets set-fix-ink-widgets!
          fix-ink-remove!
 
-         <text-ink> set-text-ink-position!
+         <text-ink> text-ink? set-text-ink-position!
 
          <simple-text-ink> simple-text-ink? make-simple-text-ink
          simple-text-ink-text set-simple-text-ink-text!
index cba1bc9f5f2ea74535a351f1861f93ec66597408..dca6e44e625016010d7cb61c7e6571af13f29254 100644 (file)
@@ -131,11 +131,12 @@ USA.
   (parse-geometry
    geometry
    (lambda (width height x y)
-     ;; Set-screen-size! will not work here.
+     (declare (ignore x y))
+     ;; For make-editor-frame:
      (set-screen-x-size! screen width)
      (set-screen-y-size! screen height)
      (let ((toplevel (gtk-screen-toplevel screen)))
-       ;; This allows the luser to resize to smaller than the logical size.
+       ;; This allows the user to resize to smaller sizes.
        (gtk-window-set-geometry-hints toplevel toplevel
                                      'min-width 100 'min-height 100)))))
 
@@ -988,15 +989,19 @@ USA.
   widget)
 
 (define-method gtk-object-destroy-callback ((widget <text-widget>))
+  ;; NOTE that this callback can be called before a widget is realized(!).
   (call-next-method widget)
   (let ((cursor (text-widget-cursor-ink widget)))
     (if cursor
-       (begin
+       (let ((mark (cursor-ink-point cursor)))
          (fix-ink-remove! cursor)
-         (mark-temporary! (cursor-ink-point cursor)))))
-  (gobject-unref!
-   (text-ink-pango-layout
-    (car (fix-drawing-display-list (text-widget-override-drawing widget))))))
+         (if mark (mark-temporary! mark)))))
+  (and-let* ((drawing (text-widget-override-drawing widget))
+            (ink (car (fix-drawing-display-list drawing)))
+            ((text-ink? ink))
+            (layout (text-ink-pango-layout ink)))
+    (gobject-unref! layout))
+  unspecific)
 
 (define-method fix-layout-realize-callback ((widget <text-widget>))
   (%trace ";(fix-layout-realize-callback <text-widget>) "widget"\n")