fix: cpu load high.
This commit is contained in:
parent
c5b07ff321
commit
9a8751c7c8
|
@ -145,19 +145,6 @@ int Document::blockEnded(int line)
|
|||
|
||||
int Document::maxLineWidth() {
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (mIndexOfLongestLine < 0) {
|
||||
int MaxLen = -1;
|
||||
mIndexOfLongestLine = -1;
|
||||
if (mLines.count() > 0 ) {
|
||||
for (int i=0;i<mLines.size();i++) {
|
||||
int len = mLines[i]->mWidth;
|
||||
if (len > MaxLen) {
|
||||
MaxLen = len;
|
||||
mIndexOfLongestLine = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mIndexOfLongestLine >= 0) {
|
||||
return mLines[mIndexOfLongestLine]->width();
|
||||
} else
|
||||
|
@ -1179,7 +1166,7 @@ void Document::endSetLinesWidth()
|
|||
mSetLineWidthLockCount--;
|
||||
if (mSetLineWidthLockCount == 0) {
|
||||
if (mMaxLineChangedInSetLinesWidth)
|
||||
emit maxLineWidthChanged();
|
||||
updateMaxLineWidthAndNotify();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1195,30 +1182,47 @@ void Document::setLineWidth(int line, const QString &lineText, int newWidth, con
|
|||
mLines[line]->mGlyphStartPositionList = glyphStartPositionList;
|
||||
if (mIndexOfLongestLine<0) {
|
||||
mIndexOfLongestLine = line;
|
||||
notifyMaxLineWidthChanged();
|
||||
updateMaxLineWidthChanged();
|
||||
} else if (mIndexOfLongestLine == line) {
|
||||
if (oldWidth > newWidth) {
|
||||
mIndexOfLongestLine = -1;
|
||||
notifyMaxLineWidthChanged();
|
||||
} else {
|
||||
notifyMaxLineWidthChanged();
|
||||
updateMaxLineWidthChanged();
|
||||
} else if (oldWidth < newWidth) {
|
||||
updateMaxLineWidthChanged();
|
||||
}
|
||||
} else if (mLines[mIndexOfLongestLine]->mWidth < newWidth) {
|
||||
mIndexOfLongestLine = line;
|
||||
notifyMaxLineWidthChanged();
|
||||
updateMaxLineWidthChanged();
|
||||
}
|
||||
Q_ASSERT(mLines[line]->mGlyphStartPositionList.length() == mLines[line]->mGlyphStartCharList.length());
|
||||
}
|
||||
|
||||
void Document::notifyMaxLineWidthChanged()
|
||||
void Document::updateMaxLineWidthChanged()
|
||||
{
|
||||
if (mSetLineWidthLockCount>0) {
|
||||
mMaxLineChangedInSetLinesWidth = true;
|
||||
} else {
|
||||
emit maxLineWidthChanged();
|
||||
updateMaxLineWidthAndNotify();
|
||||
}
|
||||
}
|
||||
|
||||
void Document::updateMaxLineWidthAndNotify()
|
||||
{
|
||||
int MaxLen = -1;
|
||||
mIndexOfLongestLine = -1;
|
||||
if (mLines.count() > 0 ) {
|
||||
for (int i=0;i<mLines.size();i++) {
|
||||
int len = mLines[i]->mWidth;
|
||||
if (len > MaxLen) {
|
||||
MaxLen = len;
|
||||
mIndexOfLongestLine = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mIndexOfLongestLine>=0)
|
||||
emit maxLineWidthChanged();
|
||||
}
|
||||
|
||||
QList<int> Document::calcGlyphPositionList(const QString &lineText, const QList<int> &glyphStartCharList, int left, int &right) const
|
||||
{
|
||||
return calcGlyphPositionList(lineText, glyphStartCharList,
|
||||
|
|
|
@ -579,7 +579,8 @@ private:
|
|||
void beginSetLinesWidth();
|
||||
void endSetLinesWidth();
|
||||
void setLineWidth(int line, const QString& lineText, int newWidth, const QList<int> glyphStartPositionList);
|
||||
void notifyMaxLineWidthChanged();
|
||||
void updateMaxLineWidthChanged();
|
||||
void updateMaxLineWidthAndNotify();
|
||||
|
||||
int glyphWidth(const QString& glyph, int left,
|
||||
const QFontMetrics &fontMetrics,
|
||||
|
|
|
@ -930,7 +930,6 @@ void QSynEdit::invalidateLines(int firstLine, int lastLine)
|
|||
{
|
||||
if (!isVisible())
|
||||
return;
|
||||
// qDebug()<<"invalidate lines:"<<firstLine<<lastLine;
|
||||
if (firstLine == -1 && lastLine == -1) {
|
||||
QRect rcInval = clientRect();
|
||||
rcInval.setLeft(rcInval.left()+mGutterWidth);
|
||||
|
|
Loading…
Reference in New Issue