Page 1 of 1

Problem with DependencyProperty (Help)

Posted: 07 Dec 2018, 10:56
by Wanderer
I want use DependencyProperty, everything looks OK, I copy my old code from old project which was working without problems, I only change the class and naming of objects.

here is code which make trouble: (If I coment problematic code, project is compiled without error and is running ok), I tried Beta4 or 2.1 final, same error
NS_IMPLEMENT_INLINE_REFLECTION(grid_UrhoControl, Noesis::UserControl)
	{
		NsMeta<Noesis::TypeId>("SumpleUI.grid_UrhoControl");
		Noesis::Ptr<Noesis::UIElementData> data = NsMeta<Noesis::UIElementData>(Noesis::TypeOf<SelfClass>()); // !!! this throw error
		/*data->RegisterProperty<bool>(b_IsChecked_LightsProperty, "b_IsChecked_Lights",
			Noesis::FrameworkPropertyMetadata::Create());*/
	}
When I compile, it throw this:
Severity	Code	Description	Project	File	Line	Suppression State
Error	C2440	'initializing': cannot convert from 'T *' to 'Noesis::Ptr<Noesis::UIElementData>'	U3D Noesis Console DX	d:\... \grid_urhocontrol.h	59	
1>grid_UrhoControl.cpp
1>d:\...\urho3d test 2018\u3d noesis console dx\grid_urhocontrol.h(59): error C2440: 'initializing': cannot convert from 'T *' to 'Noesis::Ptr<Noesis::UIElementData>'
1>        with
1>        [
1>            T=Noesis::UIElementData
1>        ]
1>d:\...\u3d noesis console dx\grid_urhocontrol.h(59): note: Constructor for class 'Noesis::Ptr<Noesis::UIElementData>' is declared 'explicit'
1>d:\programi\development\noesis-gui\noesisgui-nativesdk-2.2.0b4\include\nscore\typeclasscreator.inl(38): note: see reference to function template instantiation 'void grid_UrhoControl::StaticFillClassType<void>(Noesis::TypeClassCreator &)' being compiled
1>d:\...\urho3d test 2018\u3d noesis console dx\grid_urhocontrol.h(56): note: see reference to function template instantiation 'void Noesis::TypeClassCreator::Fill<grid_UrhoControl::SelfClass,grid_UrhoControl::ParentClass>(Noesis::Type *)' being compiled
1>MainWindow.cpp
1>d:\...\games\urho3d test 2018\u3d noesis console dx\grid_urhocontrol.h(59): error C2440: 'initializing': cannot convert from 'T *' to 'Noesis::Ptr<Noesis::UIElementData>'
1>        with
1>        [
1>            T=Noesis::UIElementData
1>        ]
1>d:\...\urho3d test 2018\u3d noesis console dx\grid_urhocontrol.h(59): note: Constructor for class 'Noesis::Ptr<Noesis::UIElementData>' is declared 'explicit'
1>d:\programi\development\noesis-gui\noesisgui-nativesdk-2.2.0b4\include\nscore\typeclasscreator.inl(38): note: see reference to function template instantiation 'void grid_UrhoControl::StaticFillClassType<void>(Noesis::TypeClassCreator &)' being compiled
1>d:\...\urho3d test 2018\u3d noesis console dx\grid_urhocontrol.h(56): note: see reference to function template instantiation 'void Noesis::TypeClassCreator::Fill<grid_UrhoControl::SelfClass,grid_UrhoControl::ParentClass>(Noesis::Type *)' being compiled

Re: Problem with DependencyProperty (Help)

Posted: 07 Dec 2018, 14:57
by Wanderer
Hmm I tested my old project, and same problem. I used VisualStudio 2015 and now I have 2017. But I can't believe this can be problem because I compile my current project, even it run, until I use UIElementData for register DependencyProperty.

Re: Problem with DependencyProperty (Help)

Posted: 07 Dec 2018, 17:48
by sfernandez
Please try the following code, it should compile fine with latest 2.2.0b4:
NS_IMPLEMENT_INLINE_REFLECTION(grid_UrhoControl, Noesis::UserControl)
{
    NsMeta<Noesis::TypeId>("SumpleUI.grid_UrhoControl");
    Noesis::UIElementData* data = NsMeta<Noesis::UIElementData>(Noesis::TypeOf<SelfClass>());
    data->RegisterProperty<bool>(b_IsChecked_LightsProperty, "b_IsChecked_Lights",
        Noesis::FrameworkPropertyMetadata::Create());
}

Re: Problem with DependencyProperty (Help)

Posted: 07 Dec 2018, 18:10
by Wanderer
Thanks, now it is working. It is strange this was working before.

Re: Problem with DependencyProperty (Help)

Posted: 07 Dec 2018, 21:32
by sfernandez
We changed the return type of NsMeta<T> from Ptr<T> to T* for 2.2 version, that is why it was working before the other way.