ecode: Fix crash when opening a new terminal.

This commit is contained in:
Martín Lucas Golini
2022-12-07 01:44:43 -03:00
parent 4e61552126
commit 4e8caa82c2
3 changed files with 6 additions and 4 deletions

View File

@@ -107,7 +107,8 @@ class EE_API UICodeEditorSplitter {
const std::string& path, std::shared_ptr<ThreadPool> pool,
std::function<void( UICodeEditor*, const std::string& )> onLoaded, UITabWidget* tabWidget );
void removeUnusedTab( UITabWidget* tabWidget );
void removeUnusedTab( UITabWidget* tabWidge, bool destroyOwnedNode = true,
bool immediateCloset = true );
UITabWidget* createEditorWithTabWidget( Node* parent, bool openCurEditor = true );

View File

@@ -459,7 +459,8 @@ UICodeEditorSplitter::createWidgetInTabWidget( UITabWidget* tabWidget, UIWidget*
return std::make_pair( tab, widget );
}
void UICodeEditorSplitter::removeUnusedTab( UITabWidget* tabWidget ) {
void UICodeEditorSplitter::removeUnusedTab( UITabWidget* tabWidget, bool destroyOwnedNode,
bool immediateClose ) {
if ( tabWidget && tabWidget->getTabCount() >= 2 &&
tabWidget->getTab( 0 )->getOwnedWidget()->isType( UI_TYPE_CODEEDITOR ) &&
tabWidget->getTab( 0 )
@@ -467,7 +468,7 @@ void UICodeEditorSplitter::removeUnusedTab( UITabWidget* tabWidget ) {
->asType<UICodeEditor>()
->getDocument()
.isEmpty() ) {
tabWidget->removeTab( (Uint32)0, true, true );
tabWidget->removeTab( (Uint32)0, destroyOwnedNode, immediateClose );
}
}

View File

@@ -183,7 +183,7 @@ UITerminal* TerminalManager::createNewTerminal( const std::string& title, UITabW
term->getTerm()->getTerminal()->setAllowMemoryTrimnming( true );
auto ret = mApp->getSplitter()->createWidgetInTabWidget(
tabWidget, term, title.empty() ? mApp->i18n( "shell", "Shell" ).toUtf8() : title, true );
mApp->getSplitter()->removeUnusedTab( tabWidget );
mApp->getSplitter()->removeUnusedTab( tabWidget, true, false );
ret.first->setIcon( mApp->findIcon( "filetype-bash" ) );
term->setTitle( title );
auto csIt = mTerminalColorSchemes.find( mTerminalCurrentColorScheme );