Issue #1786: Python Console crashes when applying after clearing
This patch attempts to resolve issue #1786 (closed) in 2.10 (as it is already resolved in 2.99).
According to the documentation, buffer.get_iter_at_line_offset ()
does not allow invalid offsets in GTK2 (in GTK3, it returns the end iterator if char_offset
exceeds the line size). The iter is invalid when "Apply" is used after the console is cleared (it tries to move +4 past the start, which is impossible with an empty buffer). Therefore, attempts to delete the buffer, place the cursor, and insert the command crash the console.
To prevent this, the line indicator >>>
is re-added to the console when the Clear button is clicked (after everything else is deleted). This allows buffer.get_iter_at_line_offset ()
to still work correctly after clearing the console.
(It also seems more consistent with how clear
works in the terminal)
Feedback appreciated!