ecode: Don't crash if the terminal could not initialize.

Closes issue SpartanJ/ecode#81.
This commit is contained in:
Martín Lucas Golini
2023-03-19 13:14:14 -03:00
parent de3601da95
commit 13f2dce2ca
2 changed files with 17 additions and 2 deletions
@@ -39,8 +39,10 @@ bool UITerminal::isType( const Uint32& type ) const {
}
void UITerminal::draw() {
mTerm->setPosition( mScreenPosi.asFloat() );
mTerm->draw();
if ( mTerm ) {
mTerm->setPosition( mScreenPosi.asFloat() );
mTerm->draw();
}
}
UITerminal::UITerminal( const std::shared_ptr<TerminalDisplay>& terminalDisplay ) :
@@ -49,6 +51,8 @@ UITerminal::UITerminal( const std::shared_ptr<TerminalDisplay>& terminalDisplay
mVScroll( UIScrollBar::NewVertical() ),
mTerm( terminalDisplay ) {
mFlags |= UI_TAB_STOP;
if ( !terminalDisplay )
return;
mTerm->pushEventCallback( [&]( const TerminalDisplay::Event& event ) {
switch ( event.type ) {
case TerminalDisplay::EventType::TITLE: {
@@ -297,6 +301,8 @@ const std::shared_ptr<TerminalDisplay>& UITerminal::getTerm() const {
}
void UITerminal::scheduledUpdate( const Time& ) {
if ( !mTerm )
return;
mTerm->update();
if ( mTerm->isDirty() )
+9
View File
@@ -258,6 +258,15 @@ UITerminal* TerminalManager::createNewTerminal( const std::string& title, UITabW
mApp->termConfig().fontSize.asPixels( 0, Sizef(), mApp->getDisplayDPI() ), initialSize,
program, args, !workingDir.empty() ? workingDir : mApp->getCurrentWorkingDir(), 10000,
nullptr, mUseFrameBuffer );
if ( term->getTerm() == nullptr ) {
UIMessageBox* msgBox = UIMessageBox::New(
UIMessageBox::OK,
mApp->i18n( "feature_not_supported_in_os",
"This feature is not supported in this Operating System" ) );
msgBox->showWhenReady();
return nullptr;
}
term->getTerm()->getTerminal()->setAllowMemoryTrimnming( true );
auto ret = mApp->getSplitter()->createWidgetInTabWidget(
tabWidget, term, title.empty() ? mApp->i18n( "shell", "Shell" ).toUtf8() : title, true );