No announcement yet.

Code runs perfectly but not when it's put in a function?!?!?

  • Filter
  • Time
  • Show
Clear All
new posts

    Code runs perfectly but not when it's put in a function?!?!?

    A plugin needs to connect to a socket server, then start a loop in which a texture is updated with data streamed through TCP/IP.

    First, I use ConnectionSocket->Connect
    Then I use
    TFuture<void> ClientConnectionFinishedFuture;
    ClientConnectionFinishedFuture = RunLambdaOnBackGroundThread([&]()

    to start code when the connection is established.

    Now in this backgroundthread block I update pixel data in an array, and call UpdateTextureRegions to put that data in the texture.

    All I want to do is take that perfectly running code and put it in a function but when I do that the editor crashes asking for missing unreal-editor.pdb (so basically it's crashing inside the Epic code not my plugin).

    I am pretty sure this has something to do with threading, but normally (ex in C#) whatever thread/context you're in, you can always put code in another function which is executed serially and within the same thread/context.

    I cannot fathom why putting code in a function would break anything. Let me know if the information above is sufficient to have some clues.

    Seems like it's something to do with this being a lambda function. [&] should capture [this] by default and should allow you to call any method. However I'm not sure how that works with UPROPERTY.