OSDN Git Service

* memwin.ith (error_dialog): Declare public method.
authorkseitz <kseitz>
Tue, 22 May 2001 19:02:54 +0000 (19:02 +0000)
committerkseitz <kseitz>
Tue, 22 May 2001 19:02:54 +0000 (19:02 +0000)
* memwin.itb (error_dialog): Define.
(edit): When attempting to set memory, post an error dialog
if gdb told us an error occurred while writing the memory.

gdb/gdbtk/ChangeLog
gdb/gdbtk/library/memwin.itb
gdb/gdbtk/library/memwin.ith

index d09a0af..3ec8145 100644 (file)
@@ -1,5 +1,12 @@
 2001-05-22  Keith Seitz  <keiths@cygnus.com>
 
+       * memwin.ith (error_dialog): Declare public method.
+       * memwin.itb (error_dialog): Define.
+       (edit): When attempting to set memory, post an error dialog
+       if gdb told us an error occurred while writing the memory.
+
+2001-05-22  Keith Seitz  <keiths@cygnus.com>
+
        * library/interface.tcl (gdbtk_tcl_file_changed): Handle
        the case of empty-string files, sent by gdb when the
        user requests to reset the file.
index adc8ed7..139f202 100644 (file)
@@ -289,7 +289,14 @@ body MemWin::edit { cell } {
     foreach c [split $val ""] {
       if {$c != $ascii_char} {
        if {$c == "'"} {set c "\\'"}
-       catch {gdb_cmd "set *(char *)($addr) = '$c'"}
+       set err [catch {gdb_cmd "set *(char *)($addr) = '$c'"} res]
+       if {$err} {
+         error_dialog [winfo toplevel $itk_interior] $res
+
+         # reset value
+         set ${this}_memval($row,$col) $saved_value
+         return
+       }
       }
       incr addr
     }
@@ -315,7 +322,15 @@ body MemWin::edit { cell } {
   set addr [expr {$current_addr + $bytes_per_row * $row + $size * $col}]
   #debug "  edit $row,$col         [format "%x" $addr] = $val"
   #set memory
-  catch {gdb_cmd "set *($type($size) *)($addr) = $val"} res
+  set err [catch {gdb_cmd "set *($type($size) *)($addr) = $val"} res]
+  if {$err} {
+    error_dialog [winfo toplevel $itk_interior] $res
+
+    # reset value
+    set ${this}_memval($row,$col) $saved_value
+    return
+  }
+
   # read it back
   # FIXME - HACK ALERT - This call causes trouble with remotes on Windows. 
   # This routine is in fact called from within an idle handler triggered by
@@ -769,3 +784,17 @@ body MemWin::memMoveCell {w x y} {
   $w activate $r,$c
   $w see active
 }
+
+# ------------------------------------------------------------
+#  PUBLIC METHOD:  error_dialog - Open and error dialog.
+#    Arguments:
+#        msg      - The message to display in the dialog
+#        modality - The dialog modailty. Default: task
+#        type     - The dialog type (tk_messageBox).
+#                    Default: ok
+# ------------------------------------------------------------
+body MemWin::error_dialog {msg {modality task} {type ok}} {
+  set parent [winfo toplevel [namespace tail $this]]
+  tk_messageBox -icon error -title Error -type $type \
+    -modal $modality -message $msg -parent $parent
+}
index fd2bc0d..a8a770e 100644 (file)
@@ -74,5 +74,6 @@ class MemWin {
     method do_popup {x y}
     method goto {addr}
     method memMoveCell {w x y}
+    method error_dialog {msg {modality task} {type ok}}
   }
 }