Page 1 of 2

"Unable to create Nude pointer for input parameter"

PostPosted: Mon Apr 18, 2016 4:44 pm
by SteveW
Hello,

Now I have sorted out my build problems and have a project based on Qt 5.6.0 and QxORM 1.4.2, I am attempting to get to bottom of the last actual issue I had with QxORM generated code (post viewtopic.php?f=2&t=463#p1399), but I have another issue now preventing me from being able to look at that. Or maybe it is the same issue, but because the debug build ASSERT's and release doesn't, they just look like different things. I won't know until I'm passed the problem I will desribe below...

From the front end Qt Quick/QML application we have the code:

C++
Code: Select all
   QQuickView qmlView;
   QString sQmlFile = "qrc:/main.qml";
   qmlView.rootContext()->setContextProperty("customer_main_record", pModel);
   qmlView.setSource(QUrl(sQmlFile));
   qmlView.show();


And then when a button is clicked the fetch_all is issued:

QML
Code: Select all
Button {
         text: "Fetch All"
         onClicked: customer_main_record.qxFetchAll_()
      }


When the button is clicked, the server picks up the request ok, and eventually ends up in:

Code: Select all
qx_bool QxConvert_FromJson_Helper(const QJsonValue & j, qx::service::QxTransaction & t, const QString & format)
...
      qx::service::IxParameter * ptr = qx::create_nude_ptr<qx::service::IxParameter>(sClassName);
      if (! ptr) { qAssertMsg(false, "[QxOrm] qx::cvt::detail::QxConvert_FromJson< qx::service::QxTransaction >, loading QJson", "unable to create nude pointer for input parameter"); }


Which then ASSERTS with ptr=NULL because it cannot create the "nude_ptr". sClassName at this point is: "customer_main_record_input".

I have examined the m_mapFactoryX collection inside QxFactoryX::createObjectNudePtr, and it is a populated collection (count=156 items, some "empty" items, and some which correspond to our database schema). Related to the table in question, one of the collection items is "services::customer_main_record_input". (See screenshot of debug output - sorry for the poor resolution i had to resize to fit it into the forum's 256Kb limit).

I can see that this item was added to the collection via the line:

Code: Select all
QX_REGISTER_COMPLEX_CLASS_NAME_CPP_CRM_SERVICES(services::customer_main_record_input, services_customer_main_record_input)


inside the generated source code file "customer_main_record.services.gen.cpp"

The issue seems to be that sClassName = "customer_main_record_input" but the name of the key in the collection is "services::customer_main_record_input".

I am not sure what to do next?

Thanks,
Steve

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Mon Apr 18, 2016 7:08 pm
by qxorm
Hello,

The issue seems to be that sClassName = "customer_main_record_input" but the name of the key in the collection is "services::customer_main_record_input".

Yes I think you are right.

The problem seems to come from the macro : QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP (defined in file ./include/QxService/IxParameter.h of QxOrm packge) :
Code: Select all
#define QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(className) \
QX_SERVICE_IX_PARAMETER_QDATASTREAM_CPP(className) \
QX_SERVICE_IX_PARAMETER_QJSON_CPP(className) \
void className::registerClass() const { qx::QxClass< className >::getSingleton(); } \
QString className::getClassName() const { return #className; }

The last line returns the class name passed to the macro.
In case of classes inside namespace, this macro needs the full class name, including namespace.

And it seems that QxEntityEditor puts just class name, without namespace :
Code: Select all
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(blog_input)
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(blog_output)

Instead of :
Code: Select all
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(services::blog_input)
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(services::blog_output)


In the attached screenshot, I think @@CLASS_NAME@@ should be replaced by @@FULL_CLASS_NAME@@.
Could you please try that ?

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Tue Apr 19, 2016 12:42 am
by SteveW
I setup the QxEE settings as per screenshot(s)

I could not change the "Default" code pane in QxEE, so I had to set "Custom" mode, then copy the Default code to the Custom tab and make the edits there. And then I had had to be careful because it would generate blank .H custom code instead of the Default .H, so I had to also copy the Default .H code into the Custom tab. This was quite easy to get wrong, and end up with blank code in my Custom tabs when making the code changes - in the end I had to copy code to a temp editor to save it being deleted when switching from Default to Custom.

Well finally when I had it set up as per screenshots, I generated code.

My bad, but then I went ahead and rebuilt the entire project (2 hours building time), and then when I ran it I received the same error.

On inspection of the generated CPP code, it does not seem to have picked up my Custom code because it still reads...

Code: Select all
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(customer_main_record_input)
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(customer_main_record_output)


Did I use QxEE incorrectly?

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Tue Apr 19, 2016 12:42 am
by SteveW
.H Screenshot

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Tue Apr 19, 2016 12:42 am
by SteveW
.CPP screenshot

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Tue Apr 19, 2016 7:17 am
by qxorm
Your C++ services export settings seems OK.
I think you selected the wrong export button : please export the services classes.
And then, before compiling, check your files in : c:\__sum-it\dorothy\dorothy\code\crm\service\source\

Note : you don't have to rebuild everything !
You just change *.cpp services files.
So just build (not rebuild) your services project.

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Tue Apr 19, 2016 11:34 am
by SteveW
Hi

I did not use the wrong export button. I re-export the Services code after updating the templates.

Also If I change the option from Default Custom and then update CPP file template, then it generates blank .H files unless I add code to the Custom.H file tab. You cannot have "Default .H" and "Custom.CPP". And the because all the .H files change, all the dependant projects (Model View, Client Service etc) need to be rebuilt (which takes ~2 hours with the database schema we are using).

Anyway, today I regenerated it again, only this time adding some test comments to be sure it was regenerating my code as I expected it...

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Tue Apr 19, 2016 11:36 am
by SteveW
And the generated code looks like this: (sorry for splitting post, forum only allows 1 screen shot per post).

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Tue Apr 19, 2016 6:16 pm
by qxorm
Hello

And the because all the .H files change, all the dependant projects (Model View, Client Service etc) need to be rebuilt (which takes ~2 hours with the database schema we are using)

If you don't want that your headers change between 2 exports, you could remove the @@COMMENT_FILE_CREATED_BY@@ placeholder from *.h template.

I did not use the wrong export button. I re-export the Services code after updating the templates.

Yes sorry it's my fault : I gave you the wrong placeholder !
Instead of @@FULL_CLASS_NAME@@ (which refers to the entity itself and not the service), replace it by : @@FULL_CLASS_NAME_SERVICES@@

So it should be :
Code: Select all
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(@@FULL_CLASS_NAME_SERVICES@@_input)
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(@@FULL_CLASS_NAME_SERVICES@@_output)


If it works fine, I will provide you a new version where the default template is fixed.

If I change the option from Default Custom and then update CPP file template, then it generates blank .H files unless I add code to the Custom.H file tab. You cannot have "Default .H" and "Custom.CPP".

I will improve that in a future release : I think I will add a button to copy/past automatically the default h/cpp template to custom.
And a QxEntityEditor manual (like the QxOrm manual) will be available soon : it should help users to understand/customize the export process...

Re: "Unable to create Nude pointer for input parameter"

PostPosted: Thu Apr 21, 2016 12:26 pm
by SteveW
Hi. Thanks yes, using that updated template now generates working code. (It also runs in Debug & Release and with both compilers),

ALso, so my previous issue

Code: Select all
"invalid input parameter to call service 'customer_main_record_services::fetchAll()'"



Is gone, so must also have been related to this too.

My only final curiosity is that I did have a working build, MSVC only, (in MinGW it crashed in boost serialization) using default code, not modified templates, when I was using the BETA QxEE/QxORM you'd supplied together with Qt 5.5.0, boost serialization. It was only when moving to Qx Serialization that I think this started happening. Anyway I'm not worried about what changed between then and now, now that we are up and running, but just highlighting the fact modified template code never used to be required.