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"

Very anoing bug/ crash UMG/ UUSerWidget and delegates.

So been trying all day to figuer out way my Editor crashes when pressing Stop/ Esc in PiE.

And i managed to figure out that it is the delegates in my extended UUSerWidget::. I have over-riden the method like this:

 void UInventoryUserWidget::Construct_Implementation()
 {
     Super::Construct_Implementation();
 
     AMyPlayerController* PC = Cast<AMyPlayerController>(GetOwningPlayer());
     if ((PC) && PC->IsValidLowLevel())
     {
         if (PC->OnPlayerPickupItem.IsBound())
             PC->OnPlayerPickupItem.RemoveDynamic(this, &UInventoryUserWidget::CallPlayerPickupItem);
 
         if (PC->OnPlayerInventoryUpdated.IsBound())
             PC->OnPlayerInventoryUpdated.RemoveDynamic(this, &UInventoryUserWidget::CallInventoryUpdated);
 
         // Calls CallPlayerPickupItem() that in turn calls the "BlueprintImplementableEvent" on OnPlayerPickedItem()
         if (!PC->OnPlayerPickupItem.IsBound())
             PC->OnPlayerPickupItem.AddDynamic(this, &UInventoryUserWidget::CallPlayerPickupItem);
 
         // Calls CallInventoryUpdated() that in turn calls the "BlueprintImplementableEvent" on OnInventoryUpdated()
         if (!PC->OnPlayerInventoryUpdated.IsBound())
             PC->OnPlayerInventoryUpdated.AddDynamic(this, &UInventoryUserWidget::CallInventoryUpdated);
 
         OnConstructedDone();
     }
 }

Is this wrong or what am i doing wrong here?

I asked a similar qustion on the forums a time back and this is the solution.

But running this outside the editor and it don`t crash.

Am running out of ideas here.

WCode

Product Version: Not Selected
Tags:
more ▼

asked Dec 01 '14 at 11:39 PM in C++ Programming

avatar image

WCode
508 43 44 73

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

1 answer: sort voted first

PC

"So been trying all day to figuer out way my Editor crashes when pressing Stop/ Esc in PiE. "

I dont think it's your delegates, I think it's the use of Player Controller in a constructor!

In PIE, the PC becomes null around the time of exiting the PIE instance, and I have had crashes related to this with Solus

The solution is to make absolutely sure your are not calling the PC when it could be null, and preferrably not in a constructor that is apparently getting run on PIE exit!

Crash Pattern

The crash pattern you describe matches my experience with Playercontroller and exiting PIE, not anything to do with widgets or delegates.

Rama

more ▼

answered Dec 02 '14 at 08:58 PM

avatar image

Rama
10.7k 446 346 1090

avatar image Rama Dec 02 '14 at 09:02 PM

Suggestion

try replacing this

 AMyPlayerController* PC = Cast<AMyPlayerController>(GetOwningPlayer());

with this

 TObjectIterator<AMyPlayerController> Itr;
 if(!Itr) return; //<~~~~ this is what happens on PIE exit
 AMyPlayerController* PC = *Itr; //Safe to dereference now

This is the code I use in Solus to work around this issue !

Rama

PS: ultimately It would be best if you didnt need to access your PC in a constructor.

avatar image WCode Dec 03 '14 at 04:55 PM

Thanks for the tip :) it did not solve the problem am afraid. The crash happens as long as am exeting PiE, but only if the delegae in the UserWidget has been called.

Removing the delegates "solves" the issue. So am thinking i maybe did a stupid mistake.

Also is it preferd to only work with smart pointers/ refrences when dealing with UMG?

PS: ultimately It would be best if you didnt need to access your PC in a constructor.

Do you know of a diferent method that could work for delegate binding?

Equivelen of BeginPlay() for UserWidgets?

That whould be nice (:

Thanks

WCode

avatar image WCode Dec 11 '14 at 07:59 PM

So i finaly been able to narrow down the problem to the Clear Children Node. If i use this it crashes the editor on exit from PiE.

Anyone have any idea way this is happening i check if its all valid so it can`t be the refrence?

(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