- fix: Memory usage of undo system is not correctly calculated
- fix: Set max undo memory usage to 0 don't really remove limit of undo - fix: Set max undo times to 0 don't really remove limit of undo
This commit is contained in:
parent
d4c7ec9bb9
commit
7b290f4e44
3
NEWS.md
3
NEWS.md
|
@ -10,6 +10,9 @@ Red Panda C++ Version 2.2
|
|||
- fix: Edting / show context menu when code analysis is turned on may crash app.
|
||||
- fix: Show context menu when edting non c/c++ file may crash app.
|
||||
- fix: Project Options Dialog's Files panel will crash app.
|
||||
- fix: Memory usage of undo system is not correctly calculated
|
||||
- fix: Set max undo memory usage to 0 don't really remove limit of undo
|
||||
- fix: Set max undo times to 0 don't really remove limit of undo
|
||||
|
||||
Red Panda C++ Version 2.1
|
||||
|
||||
|
|
|
@ -6599,16 +6599,16 @@ bool SynEdit::modified() const
|
|||
return mModified;
|
||||
}
|
||||
|
||||
void SynEdit::setModified(bool Value)
|
||||
void SynEdit::setModified(bool value)
|
||||
{
|
||||
if (Value) {
|
||||
if (value) {
|
||||
mLastModifyTime = QDateTime::currentDateTime();
|
||||
emit statusChanged(StatusChange::scModified);
|
||||
}
|
||||
if (Value != mModified) {
|
||||
mModified = Value;
|
||||
if (value != mModified) {
|
||||
mModified = value;
|
||||
|
||||
if (Value) {
|
||||
if (value) {
|
||||
mUndoList->clear();
|
||||
mRedoList->clear();
|
||||
} else {
|
||||
|
@ -6648,7 +6648,8 @@ void SynEdit::setUndoLimit(int size)
|
|||
|
||||
void SynEdit::setUndoMemoryUsage(int size)
|
||||
{
|
||||
mUndoList->setMaxMemoryUsage(size*1024*1024);
|
||||
// mUndoList->setMaxMemoryUsage(size*1024*1024);
|
||||
mUndoList->setMaxMemoryUsage(size*1024*1024);
|
||||
}
|
||||
|
||||
int SynEdit::charsInWindow() const
|
||||
|
|
|
@ -989,9 +989,9 @@ PUndoItem UndoList::popItem()
|
|||
// qDebug()<<"popped"<<item->changeNumber()<<item->changeText()<<(int)item->changeReason()<<mLastPoppedItemChangeNumber;
|
||||
if (mLastPoppedItemChangeNumber!=item->changeNumber() && item->changeReason()!=ChangeReason::GroupBreak) {
|
||||
mBlockCount--;
|
||||
Q_ASSERT(mBlockCount>=0);
|
||||
// qDebug()<<"pop"<<mBlockCount;
|
||||
if (mBlockCount<0) {
|
||||
qDebug()<<"block count calculation error";
|
||||
mBlockCount=0;
|
||||
}
|
||||
}
|
||||
|
@ -1059,13 +1059,22 @@ bool UndoList::fullUndoImposible() const
|
|||
|
||||
void UndoList::ensureMaxEntries()
|
||||
{
|
||||
if (mMaxUndoActions>0 && (mBlockCount > mMaxUndoActions || mMemoryUsage>mMaxMemoryUsage)){
|
||||
if (mItems.isEmpty())
|
||||
return;
|
||||
// qDebug()<<QString("-- List Memory: %1 %2").arg(mMemoryUsage).arg(mMaxMemoryUsage);
|
||||
if ((mMaxUndoActions >0 && mBlockCount > mMaxUndoActions)
|
||||
|| (mMaxMemoryUsage>0 && mMemoryUsage>mMaxMemoryUsage)){
|
||||
PUndoItem lastItem = mItems.back();
|
||||
mFullUndoImposible = true;
|
||||
while ((mBlockCount > mMaxUndoActions || mMemoryUsage>mMaxMemoryUsage)
|
||||
while (((mMaxUndoActions >0 && mBlockCount > mMaxUndoActions)
|
||||
|| (mMaxMemoryUsage>0 && mMemoryUsage>mMaxMemoryUsage))
|
||||
&& !mItems.isEmpty()) {
|
||||
//remove all undo item in block
|
||||
PUndoItem item = mItems.front();
|
||||
size_t changeNumber = item->changeNumber();
|
||||
//we shouldn't drop the newest changes;
|
||||
if (changeNumber == lastItem->changeNumber())
|
||||
break;
|
||||
while (mItems.count()>0) {
|
||||
item = mItems.front();
|
||||
if (item->changeNumber()!=changeNumber)
|
||||
|
@ -1077,6 +1086,7 @@ void UndoList::ensureMaxEntries()
|
|||
mBlockCount--;
|
||||
}
|
||||
}
|
||||
// qDebug()<<QString("++ List Memory: %1").arg(mMemoryUsage);
|
||||
}
|
||||
|
||||
SelectionMode UndoItem::changeSelMode() const
|
||||
|
@ -1123,8 +1133,9 @@ UndoItem::UndoItem(ChangeReason reason, SelectionMode selMode,
|
|||
foreach (const QString& s, text) {
|
||||
length+=s.length();
|
||||
}
|
||||
mMemoryUsage -= length * sizeof(QChar) + text.length() * sizeof(QString)
|
||||
mMemoryUsage = length * sizeof(QChar) + text.length() * sizeof(QString)
|
||||
+ sizeof(UndoItem);
|
||||
// qDebug()<<mMemoryUsage;
|
||||
}
|
||||
|
||||
ChangeReason UndoItem::changeReason() const
|
||||
|
|
Loading…
Reference in New Issue