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"

Crash after adding C++ component

Hi,

After creating a new C++ component in visual studio and building it there, my Unreal Editor crashes and I am unable to open my project again. It is not happening all the time so I assume it is connected to the code I wrote, but I am not sure if it is just me or it is editor's global issue. Code that makes crashes: link:here

Product Version: UE 4.14
Tags:
more ▼

asked Apr 01 '17 at 04:30 PM in C++ Programming

avatar image

arkadeusz91
1 1 2

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

2 answers: sort voted first

Hey arkadeusz91-

The likely cause of the crash you're seeing is the GetWorld() call being made. Since the world is only valid during runtime, this call is returning null which is causing the crash. Doing a check to make sure the world exists first ( if(GetWorld())) should help prevent the crash. This goes along with Nachtmahr's suggestion of moving the code from the header file to the constructor of the source file and doing the if() check there.

Cheers

Doug Wilson

more ▼

answered Apr 05 '17 at 02:19 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
 AActor* Owner = GetOwner();
 AActor* ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn();

Don´t do this in your Header. Initialize your Variables in the Constructor instead.

more ▼

answered Apr 01 '17 at 11:26 PM

avatar image

Nachtmahr
7k 143 28 172

(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