Skip to content

Commit

Permalink
Fix crash when opening a file from the Build Issues view.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Nov 18, 2024
1 parent 877ac62 commit 1ac09d9
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/tools/ecode/statusbuildoutputcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,13 @@ void StatusBuildOutputController::setHeaderWidth() {
mTableIssues->setColumnWidth( 2, col3 );
}

static void removeRelativeSubPaths( std::string& path ) {
while ( String::startsWith( path, "../" ) || String::startsWith( path, "..\\" ) )
path = path.substr( 3 );
while ( String::startsWith( path, "./" ) || String::startsWith( path, ".\\" ) )
path = path.substr( 2 );
}

void StatusBuildOutputController::createContainer() {
if ( mContainer )
return;
Expand Down Expand Up @@ -461,6 +468,7 @@ void StatusBuildOutputController::createContainer() {
} );
} else {
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN || defined( __EMSCRIPTEN_PTHREADS__ )
removeRelativeSubPaths( path );
mApp->getDirTree()->asyncMatchTree(
ProjectDirectoryTree::MatchType::Fuzzy, path, 1,
[this, colNum, lineNum]( std::shared_ptr<FileListModel> res ) {
Expand All @@ -470,16 +478,19 @@ void StatusBuildOutputController::createContainer() {
if ( !data.isValid() )
return;
std::string path = data.toString();
UITab* tab = mSplitter->isDocumentOpen( path );
if ( !tab ) {
mApp->loadFileFromPath( path, true, nullptr,
[this, lineNum, colNum]( auto, auto ) {
onLoadDone( lineNum, colNum );
} );
} else {
tab->getTabWidget()->setTabSelected( tab );
onLoadDone( lineNum, colNum );
}
mUISceneNode->runOnMainThread( [this, path, lineNum, colNum] {
UITab* tab = mSplitter->isDocumentOpen( path );
if ( !tab ) {
mApp->loadFileFromPath(
path, true, nullptr,
[this, lineNum, colNum]( auto, auto ) {
onLoadDone( lineNum, colNum );
} );
} else {
tab->getTabWidget()->setTabSelected( tab );
onLoadDone( lineNum, colNum );
}
} );
} );
#endif
}
Expand Down

0 comments on commit 1ac09d9

Please sign in to comment.