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"

Engine crash when trying to add value to array of struct

the Engine crash when I try to add value to array of struct here is my code;

 bool USteamFriendsFunctionLibrary::DoesSaveGameExistInUserCloud(TArray<FCloudFilesHeader> &FileHeader)
 {
     IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
     TArray<FCloudFileHeader> FilesHeader;
     FCloudFileHeader Files;
 
     if (OnlineSub)
     {
         IOnlineUserCloudPtr UserCloud = OnlineSub->GetUserCloudInterface();
 
 
         if (UserCloud.IsValid())
         {
             UserCloud->GetUserFileList(*UniqueNetId, FilesHeader);
             
             if(FilesHeader.Num() > 0)
             {
                 for (int i = 0; i < FilesHeader.Num(); i++)
                 {
                     FileHeader[i].FileName = FilesHeader[i].FileName; // <----------- Crash Here
 
                     if (Files.FileName == saveName)
                     {
                         GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("FileFound!"));
                         return true;
                     }
                 }
             }
             else
             {
                 GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("FileArray = 0"));
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
     return false;
 }
 
Product Version: UE 4.19
Tags:
more ▼

asked Aug 26 '18 at 07:52 PM in C++ Programming

avatar image

brahoule
19 3 1 5

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

1 answer: sort voted first

The problem is that you are trying to set the value FileName on en element in FileHeader TArray that doesn't exist yet. You probably want to add a new FCloudFilesHeader to FileHeader, possibly via EmplaceAt or Insert, for example:

 FileHeader.EmplaceAt(i, <FCloudFilesHeader constructor arguments>);
 FileHeader[i].FileName = FilesHeader[i].FileName;

You probably don't need the second line if the FCloudFilesHeader constructor also passes the FileName.

more ▼

answered Aug 26 '18 at 09:15 PM

avatar image

pmikesell
26 1

avatar image brahoule Aug 26 '18 at 10:39 PM

I created a constructor in my struct like this;

 FCloudFilesHeader() { }

and I did like you said ;

 FileHeader.EmplaceAt(i, FCloudFilesHeader());
                     FileHeader[i].FileName = FilesHeader[i].FileName;
                     FileHeader[i].DLName = FilesHeader[i].DLName;
                     FileHeader[i].Hash = FilesHeader[i].Hash;
                     FileHeader[i].HashType = FilesHeader[i].HashType;
                     FileHeader[i].URL = FilesHeader[i].URL;
                     FileHeader[i].FileSize = FilesHeader[i].FileSize;

Now it work as it should.. no more crash! Thanks a lot for your help!

(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