From afd3fde5de41cd5c10e0953e25976912cf4cf25f Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Fri, 14 Apr 2023 16:32:23 +0200 Subject: Memory leak in Input_ #716 --- src/Fl_Input_.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx index 7842c9fca..16b2f4aae 100644 --- a/src/Fl_Input_.cxx +++ b/src/Fl_Input_.cxx @@ -88,6 +88,10 @@ public: clear(); } + int size() const { + return list_size_; + } + void push(Fl_Input_Undo_Action* action) { if (list_size_ == list_capacity_) { list_capacity_ += 25; @@ -1066,6 +1070,15 @@ int Fl_Input_::undo() { return 1; } +/** + Check if the last operation can be undone. + + \return true if the widget can unod the last change + */ +bool Fl_Input_::can_undo() { + return (undo_->undocut || undo_->undoinsert); +} + /** Redo previous undo operation. @@ -1080,6 +1093,8 @@ int Fl_Input_::redo() { if (undo_->undocut || undo_->undoinsert) undo_list_->push(undo_); + else + delete undo_; undo_ = redo_action; int ret = apply_undo(); @@ -1088,6 +1103,15 @@ int Fl_Input_::redo() { return ret; } +/** + Check if there is a redo action available. + + \return true if the widget can redo the last undo action + */ +bool Fl_Input_::can_redo() { + return (redo_list_->size() > 0); +} + /** Copies the \e yank buffer to the clipboard. -- cgit v1.2.3