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"

Editor crash on simple C++

Project is permanently hosed. It won't load in the Editor because each time at load, it crashes the Editor.

However, the first crash occurred when I tried to run the project.

Project is very simple - I was doing some simple tutorials and writing some basic C++ code. The crash happened when I tried added the following code:

 for (TObjectIterator<UAudioComponent> It; It; ++It)
         UAudioComponent* CurrentObject = *It;
         GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Red, CurrentObject->GetName());
         if (CurrentObject->GetName().Equals(FString("AudioComponent_01"), ESearchCase::IgnoreCase)) {
             fireAudio = CurrentObject;

Then later from a keybinding function (spacebar):


When I hit spacebar multiple times no sound played. The Editor then crashed and the project refused to load ever since, constantly crashing the Editor.

I realize that fireAudio could have been nullptr or random memory, which should certainly crash the game. Not sure why the project file itself seemed to get into a borked state.

I've attached my source files. Everything else is too large.link text

Product Version: UE 4.10
source.zip (6.4 kB)
more ▼

asked Mar 06 '16 at 05:31 AM in Bug Reports

avatar image

1 1 4 5

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Try next changes:
Make OurCamera as UPROPERTY() pawn variable, I suspect it can be garbage-collected.
Define fire audio like this:

 UAudioComponent * fireAudio = nullptr;

Equate OurVisibleComponent to nullptr as well.
In startGrow do null-check before call:

 if(fireAudio) fireAudio->Play();

Any unintialized variable will cause big problems hard to find. If you launched editor in debug then all uninitialized variables will have value 0xcdcdcdcd... what is the easiest way to track them.
UE4 also has Garbage Collector: if it found any data piece, that has no pointer to it then this data will be purged. GC happens at very start of editor (when it shows up) and then every 60 seconds by default. UPROPERTY variables are those that can be tracked by GC, classical pointers are not. So OurCamera will be purged instantly, as well as fireAudio.
And yeah, instead of
for(TObjectIterator It; It; ++It)
you can write
for(auto& audioComponent : TObjectIterator)
It's way accessible and faster. After you found your audio component you don't need to go further in loop, use break to end cycle inside of if field.

more ▼

answered Mar 06 '16 at 11:58 AM

avatar image

490 29 22 40

avatar image omoplata Mar 09 '16 at 08:08 PM

Ok, so I made the changes you suggested. When I tried to start the Editor, it asked if I wanted to recover changes from an unsaved map. I clicked, "no" because I didn't want it to potentially crash again.

Then the Editor started up, but has no reference to my C++ class at all. I guess this is better than nothing - I can at least start the Editor, but is there a way to add references to existing C++ code without creating new classes?

avatar image omoplata Mar 09 '16 at 08:34 PM

ah, nevermind. I just "Refresh Visual Studio Project" from the File menu.

(comments are locked)
10|2000 characters needed characters left
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