zzzlor
(zzzlor)
November 7, 2016, 7:12pm
1
===================Problem solved! ===============
Hi!
I’m trying to create a plugin . But I don’t know much about it.
While training I face a problem. I can’t use the function after clicking the button .
I used this template:
ModularBuild.h
class FModularBuildModule : public IModuleInterface
{
public:
FModularBuildModule();
//UFUNCTION()
FReply TestS();
ModularBuild.cpp
...]
TSharedRef<SDockTab> FModularBuildModule::OnSpawnPluginTab(const FSpawnTabArgs& SpawnTabArgs)
{
return SNew(SDockTab).TabRole(ETabRole::NomadTab)
// Put your tab content here!
SNew(SBox)
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
SNew(SButton)
.Text(FText::FromString(TEXT("Push")))
.ContentPadding(3)
.OnClicked(this, &FModularBuildModule::TestS)
]
];
}
...]
FReply FModularBuildModule::TestS()
{
UE_LOG(LogTemp, Log, TEXT("It win"));
return FReply::Handled();
}
**
Error:**
1>g:\programs\epic games\4.13\engine\source\runtime\core\public\delegates\DelegateSignatureImpl.INL(181): error c2039: total: is not a member of "FModularBuildModule"
1> G:\Programs\DeadMind\DeadMind\Plugins\ModularBuild\Source\ModularBuild\Public\ModularBuild.h(13) note: see the announcement "FModularBuildModule"
1> G:\Programs\Epic Games\4.13\Engine\Source\Environment\Slate\Public\Widgets\Input\SButton.h(54): note: see reference to instantiation of a function template at compile "TBaseDelegate<FReply> TBaseDelegate<FReply>::CreateSP<Userclass,>(Userclass *,FReply (__cdecl FModularBuildModule::* )(void))"
1>
1>
1> Userclass=FModularBuildModule
1> ]
1> G:\Programs\Epic Games\4.13\Engine\Source\Environment\Slate\Public\Widgets\Input\SButton.h(54): note: see reference to instantiation of a function template at compile "TBaseDelegate<FReply> TBaseDelegate<FReply>::CreateSP<Userclass,>(Userclass *,FReply (__cdecl FModularBuildModule::* )(void))"
1>
1>
1> Userclass=FModularBuildModule
1> ]
1> G:\Programs\DeadMind\DeadMind\Plugins\ModularBuild\Source\ModularBuild\Private\ModularBuild.cpp(78): note: see reference to instantiation of a function template at compile "SButton::FArguments::WidgetArgsType &SButton::FArguments::OnClicked<FModularBuildModule>(Userclass *,FReply (__cdecl FModularBuildModule::* )(void))"
1>
1>
1> Userclass=FModularBuildModule
1> ]
1>error : UBT error : failed to produce item: G:\Programs\DeadMind\DeadMind\Plugins\ModularBuild\Binaries\Win64\UE4Editor-ModularBuild-5456.dll
1> Total build time: 88,75 seconds
1>files c:\program (x86)\msbuild\Microsoft.CPP\V4.0\V140\Microsoft.The makefile.Targets(37,5): MSB3075 error: Output of command ""G:\Programs\Epic game engine\\4.13\build\\BatchFiles to build.bat" DeadMindEditor Win64 development "G:\Programs\DeadMind\DeadMind\DeadMind.uproject" -waitmutex"
What am I doing wrong ?
kamrann
(kamrann)
November 7, 2016, 8:15pm
2
The default Slate attribute syntax (such .OnClicked) expects a shared pointer. You need to either:
Use OnClicked_Raw instead; or
Derive your class from TSharedFromThis, which allows implicit conversion to a shared pointer, e.g.
class FModularBuildModule : public IModuleInterface, public TSharedFromThis< FModularBuildModule >
zzzlor
(zzzlor)
November 7, 2016, 9:38pm
3
Thank you very much! I was able to compile. For this I created a new Test plugin. But, alas, now my project has crashed.
MachineId:9982F49F433DDE07E8B931AE0BF7F3BF
EpicAccountId:45b4ffd3f883461792846c650903ad9c
Assertion failed: SharedThis.Get() == this [File:G:\Programs\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 1161]
UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\private\misc\outputdevice.cpp:421]
UE4Editor_Test!TSharedFromThis<FTestModule,0>::AsShared() [g:\programs\epic games\4.13\engine\source\runtime\core\public emplates\sharedpointer.h:1165]
UE4Editor_Test!TBaseDelegate<FReply>::CreateSP<FTestModule>() [g:\programs\epic games\4.13\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:181]
UE4Editor_Test!SButton::FArguments::OnClicked<FTestModule>() [g:\programs\epic games\4.13\engine\source\runtime\slate\public\widgets\input\sbutton.h:54]
UE4Editor_Test!FTestModule::OnSpawnPluginTab() [g:\programs\deadmind\deadmind\plugins est\source est\private est.cpp:73]
UE4Editor_Test!TMemberFunctionCaller<FTestModule,TSharedRef<SDockTab,0> (__cdecl FTestModule::*)(FSpawnTabArgs const & __ptr64) __ptr64>::operator()<FSpawnTabArgs const & __ptr64>() [g:\programs\epic games\4.13\engine\source\runtime\core\public\delegates\delegateinstanceinterface.h:161]
UE4Editor_Test!TTupleImpl<TIntegerSequence<unsigned int> >::ApplyAfter<TMemberFunctionCaller<FTestModule,TSharedRef<SDockTab,0> (__cdecl FTestModule::*)(FSpawnTabArgs const & __ptr64) __ptr64>,FSpawnTabArgs const & __ptr64>() [g:\programs\epic games\4.13\engine\source\runtime\core\public\delegates uple.h:115]
UE4Editor_Test!TBaseRawMethodDelegateInstance<0,FTestModule,TSharedRef<SDockTab,0> __cdecl(FSpawnTabArgs const & __ptr64)>::Execute() [g:\programs\epic games\4.13\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:546]
UE4Editor_Slate!TBaseDelegate<TSharedRef<SDockTab,0>,FSpawnTabArgs const & __ptr64>::Execute() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:521]
UE4Editor_Slate!FTabManager::SpawnTab() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:1291]
UE4Editor_Slate!FTabManager::InvokeTab_Internal() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:1013]
UE4Editor_Slate!FTabManager::InvokeTab() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:954]
UE4Editor_Test!FTestModule::PluginButtonClicked() [g:\programs\deadmind\deadmind\plugins est\source est\private est.cpp:91]
UE4Editor_Test!TBaseRawMethodDelegateInstance<0,FTestModule,void __cdecl(void)>::ExecuteIfSafe() [g:\programs\epic games\4.13\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:638]
UE4Editor_Slate!FUICommandList::ExecuteAction() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\commands\uicommandlist.cpp:92]
UE4Editor_Slate!SToolBarButtonBlock::OnClicked() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\multibox\stoolbarbuttonblock.cpp:300]
UE4Editor_Slate!TMemberFunctionCaller<SToolBarButtonBlock,FReply (__cdecl SToolBarButtonBlock::*)(void) __ptr64>::operator()<>() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\public\delegates\delegateinstanceinterface.h:161]
UE4Editor_Slate!TTupleImpl<TIntegerSequence<unsigned int> >::ApplyAfter<TMemberFunctionCaller<SToolBarButtonBlock,FReply (__cdecl SToolBarButtonBlock::*)(void) __ptr64> >() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\public\delegates uple.h:115]
UE4Editor_Slate!TBaseSPMethodDelegateInstance<0,SToolBarButtonBlock,0,FReply __cdecl(void)>::Execute() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:317]
UE4Editor_Slate!TBaseDelegate<FReply>::Execute() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:521]
UE4Editor_Slate!SButton::OnMouseButtonUp() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\widgets\input\sbutton.cpp:278]
UE4Editor_Slate!<lambda_8d0e9a1da76abd0a756a3a9d775f5ed1>::operator()() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4901]
UE4Editor_Slate!FEventRouter::Route<FReply,FEventRouter::FToLeafmostPolicy,FPointerEvent,<lambda_8d0e9a1da76abd0a756a3a9d775f5ed1> >() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:215]
UE4Editor_Slate!FSlateApplication::RoutePointerUpEvent() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4890]
UE4Editor_Slate!FSlateApplication::ProcessMouseButtonUpEvent() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:5348]
UE4Editor_Slate!FSlateApplication::OnMouseUp() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:5328]
UE4Editor_Core!FWindowsApplication::ProcessDeferredMessage() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\private\windows\windowsapplication.cpp:1584]
UE4Editor_Core!FWindowsApplication::DeferMessage() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\private\windows\windowsapplication.cpp:1930]
UE4Editor_Core!FWindowsApplication::ProcessMessage() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\private\windows\windowsapplication.cpp:747]
UE4Editor_Core!FWindowsApplication::AppWndProc() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\private\windows\windowsapplication.cpp:669]
user32
user32
UE4Editor_Core!FWindowsPlatformMisc::PumpMessages() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\core\private\windows\windowsplatformmisc.cpp:905]
UE4Editor!FEngineLoop::Tick() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2788]
UE4Editor!GuardedMain() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\launch.cpp:156]
UE4Editor!GuardedMainWrapper() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\build\++ue4+release-4.13+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll
My new code:
Test.cpp
TSharedRef<SDockTab> FTestModule::OnSpawnPluginTab(const FSpawnTabArgs& SpawnTabArgs)
{
/*FText WidgetText = FText::Format(
LOCTEXT("WindowWidgetText", "Add code to {0} in {1} to override this window's contents"),
FText::FromString(TEXT("FTestModule::OnSpawnPluginTab")),
FText::FromString(TEXT("Test.cpp"))
);
*/
return SNew(SDockTab)
.TabRole(ETabRole::NomadTab)
// Put your tab content here!
SNew(SBox)
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
SNew(SButton)
.Text(FText::FromString(TEXT("Push")))
//.ContentPadding(3)
.OnClicked(this, &FTestModule::TestS)
]
];
}
...]
FReply FTestModule::TestS()
{
UE_LOG(LogTemp, Log, TEXT("It win"));
return FReply::Handled();
}
Test.h
...]
class FTestModule : public IModuleInterface, public TSharedFromThis<FTestModule>
{
public:
FReply TestS();
...]
kamrann
(kamrann)
November 7, 2016, 10:30pm
4
Sorry, I forgot there are some limitations on using TSharedFromThis. It won’t work in this case because your class is a module and you don’t have control over how it’s constructed. So if you need to have your handlers inside your module class, you’ll have to use OnClicked_Raw instead, and remove the TSharedFromThis line.
zzzlor
(zzzlor)
November 7, 2016, 11:28pm
5
Thank you very much for the help! It worked for me.