I’m using very simple SetTime in my installed Editor Plugin.
VS building well, but Editor is crashing in approx 73% of load.
That what I see in VS Output:
...
'UE4Editor.exe' (Win32): Loaded 'C:\Program Files\Epic Games\4.7\Engine\Plugins\ScriptPlugin\Binaries\Win64\UE4Editor-ScriptEditorPlugin.dll'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Program Files\Epic Games\4.7\Engine\Plugins\Slate\SlateRemote\Binaries\Win64\UE4Editor-SlateRemote.dll'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Users\vyudin\Documents\Unreal Projects\timers\Plugins\timerPlugin\Binaries\Win64\UE4Editor-timerPlugin.dll'. Symbols loaded.
[2015.03.16-15.19.09:537][ 0]ModuleLog:Warning: *** Hi from Timer Plugin! ***
First-chance exception at 0x000007FEE6D00716 (UE4Editor-UnrealEd.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000FA0.
Unhandled exception at 0x000007FEE6D00716 (UE4Editor-UnrealEd.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000FA0.
...
My VS pointing on line 616 of SharedPointer.h from Engine Source, on this code:
// NOTE: The following is an Unreal extension to standard shared_ptr behavior
FORCEINLINE TSharedRef< ObjectType, Mode > ToSharedRef() const
{
// If this assert goes off, it means a shared reference was created from a shared pointer that was nullptr.
// Shared references are never allowed to be null. Consider using TSharedPtr instead.
check( IsValid() );
return TSharedRef< ObjectType, Mode >( *this );
}
Please find attached source code of my plugin.
Can you advise my please how to avoid crashing? Thank you in advance!
My .cpp file:
#include "timerPluginPch.h"
#include "Module.h"
#include "LevelEditor.h"
#include "UnrealEd.h"
IMPLEMENT_MODULE(Module, timerPlugin);
DEFINE_LOG_CATEGORY(ModuleLog)
Module::Module()
{
}
void Module::StartupModule()
{
UE_LOG(ModuleLog, Warning, TEXT("*** Hi from Timer Plugin! ***"));
float Seconds = (float)FTimespan::FromMinutes(0.1).GetTotalSeconds();
FTimerDelegate Delegate;
Delegate.BindRaw(this, &Module::Ticker);
GEditor->GetTimerManager()->SetTimer(TimerHandle_Ticker, Delegate, Seconds, true);
}
void Module::ShutdownModule()
{
}
void Module::Ticker()
{
UE_LOG(ModuleLog, Warning, TEXT("--- T I C K ---"));
}
My header:
#pragma once
DECLARE_LOG_CATEGORY_EXTERN(ModuleLog, Log, All)
class Module : public IModuleInterface
{
public:
Module();
virtual void StartupModule() override;
virtual void ShutdownModule() override;
private:
FTimerHandle TimerHandle_Ticker;
void Ticker();
};