Fixed leak in Fl_Text_Buffer #716

This commit is contained in:
Matthias Melcher
2023-04-14 16:54:11 +02:00
parent afd3fde5de
commit e18b5353cd
3 changed files with 40 additions and 4 deletions
+17 -1
View File
@@ -327,13 +327,29 @@ public:
*/
int undo(int *cp=0);
/**
Check if undo is anabled and if the last action can be undone.
\see canUndo()
*/
bool can_undo();
/**
Redo previous undo action.
*/
int redo(int *cp=0);
/**
Lets the undo system know if we can undo changes
Check if undo is anabled and if the last undo action can be redone.
\see canUndo()
*/
bool can_redo();
/**
Enable or disable undo actions for this text buffer.
Undo actions are enable for text buffer by default. If used as a style buffer
in Fl_Text_Display, undo actions are disabled as they are handled by the
text buffer.
\see can_undo()
*/
void canUndo(char flag=1);
+23 -1
View File
@@ -158,6 +158,10 @@ public:
clear();
}
int size() {
return list_size_;
}
void push(Fl_Text_Undo_Action* action) {
if (list_size_ == list_capacity_) {
list_capacity_ += 25;
@@ -628,6 +632,13 @@ int Fl_Text_Buffer::undo(int *cursorPos) {
return ret;
}
/*
Check if undo is anabled and if the last action can be undone.
*/
bool Fl_Text_Buffer::can_undo() {
return (mCanUndo && mUndo && !mUndo->empty());
}
/**
Redo previous undo action.
*/
@@ -642,7 +653,18 @@ int Fl_Text_Buffer::redo(int *cursorPos) {
// running the redo action will also generate a new undo action
// Note: there is a slight chance that the current undo action and the
// generated action merge into one.
return apply_undo(redo_action, cursorPos);
int ret = apply_undo(redo_action, cursorPos);
delete redo_action;
return ret;
}
/**
Check if undo is anabled and if the last undo action can be redone.
\see canUndo()
*/
bool Fl_Text_Buffer::can_redo() {
return (mCanUndo && mRedoList->size());
}
/*
-2
View File
@@ -442,8 +442,6 @@ void Fl_Text_Display::highlight_data(Fl_Text_Buffer *styleBuffer,
damage(FL_DAMAGE_EXPOSE);
}
/**
\brief Find the longest line of all visible lines.