Files
UnrealEngineUWP/Engine/Source/Developer/SourceControl/Private/SourceControlModule.h
Jamie Dale ee3213c7df Fixed crash closing the editor with SVN source control enabled
TTP# 342872 - EDITOR: Regression: CRASH: FSourceControlModule::ShutdownModule

The SVN source control provider module was being shutdown before the main source control module, leading to a crash.

The source control module now watches for its active provider module being unloaded, and will gracefully reset itself to the default (dummy) provider if that happens.

I also added these same checks to the source code access module, as it uses the same provider modules mechanism.

#codereview Thomas.Sarkanen, Max.Preussner

[CL 2244286 by Jamie Dale in Main branch]
2014-08-05 10:29:53 -04:00

120 lines
4.0 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* Interface for talking to source control clients
*/
#include "ModuleManager.h"
#include "ISourceControlModule.h"
#include "ISourceControlProvider.h"
#include "SourceControlSettings.h"
#include "DefaultSourceControlProvider.h"
class FSourceControlModule : public ISourceControlModule
{
public:
FSourceControlModule();
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/** ISourceControlModule implementation */
virtual void Tick() override;
virtual void QueueStatusUpdate(const TArray<UPackage*>& InPackages) override;
virtual void QueueStatusUpdate(const TArray<FString>& InFilenames) override;
virtual void QueueStatusUpdate(UPackage* InPackage) override;
virtual void QueueStatusUpdate(const FString& InFilename) override;
virtual bool IsEnabled() const override;
virtual ISourceControlProvider& GetProvider() const override;
virtual void SetProvider( const FName& InName ) override;
virtual void ShowLoginDialog(const FSourceControlLoginClosed& InOnSourceControlLoginClosed, ELoginWindowMode::Type InLoginWindowMode, EOnLoginWindowStartup::Type InOnLoginWindowStartup = EOnLoginWindowStartup::ResetProviderToNone) override;
virtual TSharedPtr<class SWidget> CreateStatusWidget() const override;
virtual bool GetUseGlobalSettings() const override;
virtual void SetUseGlobalSettings(bool bIsUseGlobalSettings) override;
/** Save the settings to the ini file */
void SaveSettings();
/**
* Refresh the available source control providers.
*/
void RefreshSourceControlProviders() const;
/**
* Get the number of currently registered source control providers.
*/
int32 GetNumSourceControlProviders();
/**
* Set the current source control provider by index.
*/
void SetCurrentSourceControlProvider(int32 ProviderIndex);
/**
* Get the name of the source control provider at the specified index.
*/
FName GetSourceControlProviderName(int32 ProviderIndex);
/**
* Get the one and only login widget, if any.
*/
TSharedPtr<class SSourceControlLogin> GetLoginWidget() const;
/**
* Gets a reference to the source control module instance.
*
* @return A reference to the source control module.
*/
static FSourceControlModule& Get()
{
return FModuleManager::LoadModuleChecked<FSourceControlModule>("SourceControl");
}
private:
/** Refresh & initialize the current source control provider */
void InitializeSourceControlProviders();
/** Close the current source control provider & set the current to default - 'None' */
void ClearCurrentSourceControlProvider();
/** Set the current source control provider to the passed-in value */
void SetCurrentSourceControlProvider(ISourceControlProvider& InProvider);
/** Delegate called when the source control window is closed */
void OnSourceControlDialogClosed(const TSharedRef<class SWindow>& InWindow);
/** Delegate handling when source control features are registered */
void HandleModularFeatureRegistered(const FName& Type, IModularFeature* ModularFeature);
/** Delegate handling when source control features are unregistered */
void HandleModularFeatureUnregistered(const FName& Type, IModularFeature* ModularFeature);
private:
/** The settings object */
FSourceControlSettings SourceControlSettings;
/** Current source control provider */
ISourceControlProvider* CurrentSourceControlProvider;
/** Source control provider we use if there are none registered */
FDefaultSourceControlProvider DefaultSourceControlProvider;
/** The login window we may be using */
TSharedPtr<SWindow> SourceControlLoginWindowPtr;
/** The login window control we may be using */
TSharedPtr<class SSourceControlLogin> SourceControlLoginPtr;
/** Files pending a status update */
TArray<FString> PendingStatusUpdateFiles;
/** Flag to disable source control - used temporarily when login is in progress */
bool bTemporarilyDisabled;
/** Active Provider name to track source control provider changes */
FString ActiveProviderName;
};