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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Strange null pointer exception

Hello everyone, i post this because it's been 3 hours i'm trying to resolve this strange error. This causes my editor to crash, so i now launch my editor with visual studio on debug mode.

 ULPLAYERCONTROLLER.H:
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
     TSubclassOf<class UUserWidget> wMainMenu;
 
     UUserWidget* wMainMenuRef;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
     TSubclassOf<class UUserWidget> wPlayMenu;
 
     UUserWidget* wPlayMenuRef;

so here are my references to my widgets

i initialize them here:

 ULPLAYERCONTROLLER.CPP:
 
 void AULPlayerControllerBase::SetupMenuWidgets()
 {
     if (IsLocalPlayerController())
     {
         if (wPlayMenu)
         {
             wPlayMenuRef = CreateWidget<UUserWidget>(this, wPlayMenu);
         }
         if (wMainMenu)
         {
             wMainMenuRef = CreateWidget<UUserWidget>(this, wMainMenu);
         }
     
     }
     
 }

and then i show them here:

 ULPLAYERCONTROLLER.CPP
 void AULPlayerControllerBase::BeginPlayMenuState()
 {
     if (wPlayMenu)
     {
         if (wPlayMenuRef)
         {
             if (!wPlayMenuRef->IsInViewport())
             {
                 wPlayMenuRef->AddToViewport();
             }
                 wPlayMenuRef->SetVisibility(ESlateVisibility::Visible);
             
         }
         bShowMouseCursor = true;
     }
     
 }
 void AULPlayerControllerBase::BeginMainMenuState()
 {
     if (wMainMenuRef)
     {
         if (!wMainMenuRef->IsInViewport())
         {
             wMainMenuRef->AddToViewport();
         }
 
         wMainMenuRef->SetVisibility(ESlateVisibility::Visible);
         bShowMouseCursor = true;
     }
     
 
 }

the thing i dont understand is that the project launch well, the main menu is showed and then when i naviguate to my Play Menu, i have an exception :

 Exception thrown at 0x00007FF9641289F6 (UE4Editor-UMG.dll) in UE4Editor.exe: 0xC0000005: Read access violation of location 0xFFFFFFFFFFFFFFFF.

the exception is thrown at this line:

 if (!wPlayMenuRef->IsInViewport())

the thing is that i checked this variable and this code should not be accessed if the wplaymenuref is a null pointer. Thank you for helping me, i'm confused !

Product Version: UE 4.16
Tags:
more ▼

asked Jun 12 '17 at 12:38 PM in C++ Programming

avatar image

Holiska
40 2 5 8

avatar image Holiska Jun 12 '17 at 03:39 PM

For those who have the same error, i finally figured it out. I just had to add "UPROPERTY()" to all my UUserWidget references.

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

1 answer: sort voted first

You are checking if it is NULL, that is 0x00000000. The variable is instead 0xFFFFFFFF. Thus it passes your test and it does not crash.

It is not a nullpointer exception, it is an access violation error because you try to access RAM outside of what you have. Something before it failed and windows returned 0xFFFFFFFFFF which is the invalid handle error.

HTH

more ▼

answered Jun 12 '17 at 12:58 PM

avatar image

NoobsDeSroobs
2.7k 106 34 177

avatar image Holiska Jun 12 '17 at 01:09 PM

So i don't have enough ram ? is there a way to avoid that ?

avatar image NoobsDeSroobs Jun 12 '17 at 01:32 PM

No, the problem is that the pointer returned is an error code. It failed to create the object requested, for example a window or open a file, and to tell you that it returns 0xFFFFFFFF. It is not a matter of having enough RAM.

(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