The Exception
I am currently creating a game that uses a Third Party library that I made to handle some calculations. The game launches correctly and I can play in it no problem but when I exit the player (or a standalone player) I get this exception:
Message
Output
Here is the output:
The thread 0x4a64 has exited with code 0 (0x0).
The thread 0x4a60 has exited with code 0 (0x0).
First-chance exception at 0x000007FEEC50F3A9 (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
Unhandled exception at 0x000007FEEC50F3A9 (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
Stack
And here is the stack:
UE4Editor-CoreUObject.dll!IncrementalPurgeGarbage(bool bUseTimeLimit, float TimeLimit) Line 982 C++
UE4Editor-CoreUObject.dll!CollectGarbage(EObjectFlags KeepFlags, bool bPerformFullPurge) Line 1169 C++
UE4Editor-UnrealEd.dll!UEditorEngine::EndPlayMap() Line 236 C++
UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 966 C++
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 347 C++
UE4Editor.exe!FEngineLoop::Tick() Line 2257 C++
UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 142 C++
UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 191 C++
[External Code]
Code
My code consists of two classes:
GameMapModel.h
UCLASS()
class SLTTEST2_API AGameMapModel : public AActor, public IMapModelController
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AGameMapModel();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
};
The class IMapModelController belongs to my Third Party library, GameMapModel doesn’t do anything but initialize a class in IMapModelController. Apart from that one function is called during gameplay:
IMapModelController.cpp
bool framework::IMapModelController::assignModelToController(Controller* controller)
{
if (controller != nullptr)
{
controller->setModel(mapModel);
}
else
{
throw std::invalid_argument("The controller pointer sent to assignModelToController in MapModelController has not been initialized");
}
}
This Actor is placed as is in the Map.
GameSensorPresence.h
This is my second class, a blueprint is created with it as a parent and it interacts with the GameMapModel and some of the elements in the ThirdPartyLibrary.
UCLASS(Blueprintable)
class SLTTEST2_API AGameSensorPresence : public AActor, public ISensorPresenceController, public IObserver, public enable_shared_from_this<AGameSensorPresence>
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, Category = "Sensor State")
bool on;
UPROPERTY(BlueprintReadOnly, Category = "Sensor State")
bool triggered;
UPROPERTY(BlueprintReadOnly, Category = "Sensor State")
bool ledOn;
UPROPERTY(BlueprintReadOnly, Category = "Sensor State")
float energyConsumption;
//UPROPERTY(BlueprintReadWrite, Category = "Sensor State")
ProtocolType protocol;
// Sets default values for this actor's properties
AGameSensorPresence();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
UFUNCTION(BlueprintCallable, Category = "Sensor State")
bool onDiscoveryTriggered() override;
UFUNCTION(BlueprintCallable, Category = "Sensor State")
bool onPresenceDetected(bool isPresence) override;
UFUNCTION(BlueprintCallable, Category = "Sensor State")
void onSensorOnOff(bool isOn) override;
UFUNCTION(BlueprintCallable, Category = "Sensor State")
void getSensorState();
UFUNCTION(BlueprintNativeEvent, Category = "Sensor State")
void Update() override;
UFUNCTION(BlueprintCallable, Category = "Sensor Creation")
void setProtocolType(uint8 type);
};
GameSensorPresence.cpp
I assume most of this functions should not cause any problems because I get the exception even when they are not triggered during game-play. The ones that are triggered are these:
AGameSensorPresence::AGameSensorPresence()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
this->on = true;
this->triggered = false;
this->energyConsumption = 0;
this->ledOn = false;
this->protocol = ProtocolType::DUMMY;
}
// Called when the game starts or when spawned
void AGameSensorPresence::BeginPlay()
{
Super::BeginPlay();
UWorld* world = this->GetWorld();
for (TActorIterator<AGameMapModel> It(world); It; ++It)
{
It->assignModelToController(this);
}
onSensorCreate(this, protocol);
}
Please Help!
There is all the information I think might help figure out where does this exception come from. If you need anything else just ask.
Please help!! I really need to get this working!! Thank you in advance!