Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.

Commit 202e143

Browse files
committed
fix create-compilation-databases event sent from Sourcetrail via socket was handled in non-ui thread
1 parent 30cadee commit 202e143

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

SourcetrailExtension/SourcetrailExtensionPackage.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,26 @@ async delegate
478478
else if(messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.CREATE_CDB)
479479
{
480480
Logging.Logging.LogInfo("Received request to create a compilation database.");
481-
if(_validSolutionLoaded)
481+
if (_validSolutionLoaded)
482482
{
483-
DTE dte = (DTE)GetService(typeof(DTE));
483+
ThreadHelper.JoinableTaskFactory.Run(
484+
async delegate
485+
{
486+
// Switch to main thread
487+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
488+
DTE dte = (DTE)GetService(typeof(DTE));
484489

485-
CreateCompilationDatabase(dte);
490+
CreateCompilationDatabase(dte);
491+
}
492+
);
493+
}
494+
else
495+
{
496+
Logging.Logging.LogInfo(
497+
"No C/C++ project was detected. To use the Sourcetrail Extension, please make " +
498+
"sure that the loaded Visual Studio Solution contains at least one C/C++ project " +
499+
"and Visual Studio is configured to generate a symbol database " +
500+
"(Tools->Options->Text Editor->C/C++->Advanced->Browsing/Navigation->Disable Database = False).");
486501
}
487502
}
488503
else if(messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.PING)

0 commit comments

Comments
 (0)