Fix automatic scrolling while writing in UITextEdit.

Fix threadpool close.
Git plugin safetly destruct.
This commit is contained in:
Martín Lucas Golini
2024-02-03 12:37:49 -03:00
parent db9e2634b1
commit 0fe59e3ca9
4 changed files with 24 additions and 12 deletions

View File

@@ -701,7 +701,7 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
SyntaxColorScheme mColorScheme;
UIScrollBar* mVScrollBar;
UIScrollBar* mHScrollBar;
std::unordered_map<size_t, LastXOffset> mLastXOffset;
UnorderedMap<size_t, LastXOffset> mLastXOffset;
KeyBindings mKeyBindings;
std::unordered_set<std::string> mUnlockedCmd;
Clock mLastDoubleClick;
@@ -728,7 +728,8 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
Text text;
String::HashType hash;
};
mutable std::unordered_map<Int64, TextLine> mTextCache;
mutable UnorderedMap<Int64, TextLine> mTextCache;
UnorderedMap<Int64, std::pair<String::HashType, Float>> mLinesWidthCache;
Tools::UIDocFindReplace* mFindReplace{ nullptr };
struct PluginRequestedSpace {
UICodeEditorPlugin* plugin;

View File

@@ -941,11 +941,10 @@ void UICodeEditor::updateIMELocation() {
}
void UICodeEditor::drawLockedIcon( const Vector2f start ) {
if ( mFileLockIcon == nullptr && !mFileLockIconName.empty() ) {
if ( mFileLockIcon == nullptr && !mFileLockIconName.empty() )
mFileLockIcon = getUISceneNode()->findIcon( mFileLockIconName );
if ( mFileLockIcon == nullptr )
return;
}
if ( mFileLockIcon == nullptr )
return;
Drawable* fileLockIcon = mFileLockIcon->getSize( PixelDensity::dpToPxI( 16 ) );
if ( fileLockIcon == nullptr )
@@ -1552,19 +1551,23 @@ void UICodeEditor::findLongestLine() {
Float UICodeEditor::getLineWidth( const Int64& lineIndex ) {
if ( lineIndex >= (Int64)mDoc->linesCount() )
return 0;
if ( mFont && !mFont->isMonospace() )
return Text::getTextWidth( mFont, getCharacterSize(), mDoc->line( lineIndex ).getText(),
mFontStyleConfig.Style, mTabWidth ) +
getGlyphWidth();
if ( mFont && !mFont->isMonospace() ) {
auto line = mDoc->line( lineIndex );
auto found = mLinesWidthCache.find( lineIndex );
if ( found != mLinesWidthCache.end() && line.getHash() == found->first )
return found->second.second;
Float width = getTextWidth( line.getText() ) + getGlyphWidth();
mLinesWidthCache[lineIndex] = { line.getHash(), width };
return width;
}
return getTextWidth( mDoc->line( lineIndex ).getText() );
}
void UICodeEditor::updateScrollBar() {
int notVisibleLineCount = (int)mDoc->linesCount() - (int)getViewPortLineCount().y;
if ( mLongestLineWidthDirty && mFont && mFont->isMonospace() ) {
if ( mLongestLineWidthDirty && mFont )
updateLongestLineWidth();
}
mHScrollBar->setEnabled( false );
mHScrollBar->setVisible( false );

View File

@@ -714,7 +714,10 @@ App::App( const size_t& jobs, const std::vector<std::string>& args ) :
App::~App() {
if ( mProjectBuildManager )
mProjectBuildManager.reset();
Http::setThreadPool( nullptr );
mThreadPool.reset();
if ( mFileWatcher ) {
Lock l( mWatchesLock );
delete mFileWatcher;

View File

@@ -81,6 +81,11 @@ GitPlugin::~GitPlugin() {
mStatusButton->close();
if ( mSidePanel && mTab )
mSidePanel->removeTab( mTab );
{ Lock l( mGitBranchMutex ); }
{ Lock l( mGitStatusMutex ); }
{ Lock l( mRepoMutex ); }
{ Lock l( mReposMutex ); }
}
void GitPlugin::load( PluginManager* pluginManager ) {