| 32 | } |
| 33 | |
| 34 | uint32 FGitSourceControlRunner::Run() |
| 35 | { |
| 36 | while (bRunThread) |
| 37 | { |
| 38 | StopEvent->Wait(30000); |
| 39 | if (!bRunThread) |
| 40 | { |
| 41 | break; |
| 42 | } |
| 43 | // If we're not running the task already |
| 44 | if (!bRefreshSpawned) |
| 45 | { |
| 46 | // Flag that we're running the task already |
| 47 | bRefreshSpawned = true; |
| 48 | const auto ExecuteResult = Async(EAsyncExecution::TaskGraphMainThread, [this] { |
| 49 | FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe(); |
| 50 | // Module not loaded, bail. Usually happens when editor is shutting down, and this prevents a crash from bad timing. |
| 51 | if (!GitSourceControl) |
| 52 | { |
| 53 | return ECommandResult::Failed; |
| 54 | } |
| 55 | FGitSourceControlProvider& Provider = GitSourceControl->GetProvider(); |
| 56 | TSharedRef<FGitFetch, ESPMode::ThreadSafe> RefreshOperation = ISourceControlOperation::Create<FGitFetch>(); |
| 57 | RefreshOperation->bUpdateStatus = true; |
| 58 | #if ENGINE_MAJOR_VERSION >= 5 |
| 59 | const ECommandResult::Type Result = Provider.Execute(RefreshOperation, FSourceControlChangelistPtr(), FGitSourceControlModule::GetEmptyStringArray(), EConcurrency::Asynchronous, |
| 60 | FSourceControlOperationComplete::CreateRaw(this, &FGitSourceControlRunner::OnSourceControlOperationComplete)); |
| 61 | #else |
| 62 | const ECommandResult::Type Result = Provider.Execute(RefreshOperation, FGitSourceControlModule::GetEmptyStringArray(), EConcurrency::Asynchronous, |
| 63 | FSourceControlOperationComplete::CreateRaw(this, &FGitSourceControlRunner::OnSourceControlOperationComplete)); |
| 64 | #endif |
| 65 | return Result; |
| 66 | }); |
| 67 | // Wait for result if not already completed |
| 68 | if (bRefreshSpawned && bRunThread) |
| 69 | { |
| 70 | // Get the result |
| 71 | ECommandResult::Type Result = ExecuteResult.Get(); |
| 72 | // If still not completed, |
| 73 | if (bRefreshSpawned) |
| 74 | { |
| 75 | // mark failures as done, successes have to complete |
| 76 | bRefreshSpawned = Result == ECommandResult::Succeeded; |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | void FGitSourceControlRunner::Stop() |
| 86 | { |