x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

NewObject with empty name can't be used to create default subobjects

So, I'm trying to upgrade my project, but the last error that I'm stuck on is

"NewObject with empty name can't be used to create default subobjects (inside of UObject derived class constructor) as it produces inconsistent object names. Use ObjectInitializer.CreateDefaultSuobject<> instead."

There is nothing more specific in the log, so I can't narrow it down. I have added a name to all NewObject<>() calls in constructors, but I still get the error. I have checked my code for UMaterialInstanceDynamic::Create() but I'm not using it.

Does anyone know what potential function calls would give this error if used in a constructor?

Product Version: UE 4.8
Tags:
more ▼

asked Dec 16 '15 at 04:15 AM in C++ Programming

avatar image

MasterHunter
26 1 2 2

avatar image Matthew J Dec 16 '15 at 04:37 PM

Hello MasterHunter,

There are many things that could cause this message to appear. It would be best to see your constructors where this is occurring rather than taking multiple stabs in the dark at what the issue is. Could you either upload the code files or make a pastebin link with the constructors?

avatar image MasterHunter Dec 16 '15 at 05:11 PM

Hey matthew_clark

This is a fairly big project (100+ .cpp files), so I was hoping to avoid uploading any code.

I was hoping that there was a list of functions, that when called in a constructor, are known to cause this crash in 4.8. The project works in 4.7, but we were hoping to upgrade to at least 4.9....

avatar image Matthew J Dec 16 '15 at 06:41 PM

Is there any particular reason you're using NewObject instead of CreateDefaultSubobject? As NewObject is meant to dynamically allocate memory for new objects/variables, I don't believe it can be used in the constructor at all.

As far as a list goes, there isn't really a comprehensive list of functions that won't work in the constructor. One example would be SpawnActor but there are many others.

avatar image MasterHunter Dec 16 '15 at 06:54 PM

Upgrading to a previous version of Unreal deprecated another function for the NewObject function. It's not all my code, so I'd assume that because it worked before (and there were no warnings not to) they used something other than CreateDefaultSubobject.

And to my understanding, you can use NewObject as long as it has a name passed to it. But if I get a chance, I'll change those (yet again lol) to CreateDefaultSubobject to see if it helps.

Otherwise, that's unfortunate. I would've thought these upgrade issues would've been better documented...

avatar image Matthew J Dec 21 '15 at 07:10 PM

The usage has been changed multiple times throughout the latest version updates. Usually, deprecation messages are listed in code, like the one you referenced in your original posts and sometimes in the Release Notes. Have you given CreateDefaultSuboject a try yet? I'm interested to know if that worked out better for you.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

We haven't tried to fix it further. It turns out 4.7 broke something with the behaviors and we just don't have the time to fix that anymore or fix the NewObject error

more ▼

answered Dec 21 '15 at 07:44 PM

avatar image

MasterHunter
26 1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question