Announcement

Collapse
No announcement yet.

Normal Cast vs Pure Cast - Accessed None

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Normal Cast vs Pure Cast - Accessed None

    Casting to a custom player controller:

    Click image for larger version

Name:	normalCast.PNG
Views:	1
Size:	84.2 KB
ID:	1213051

    The cast does not fail, the print string does not fire, the execution works fine but the log produces the following:

    LogScript:Warning: Accessed None trying to read property K2Node_DynamicCast_AsNS_Player_Controller
    w_POI_Label_C /Engine/Transient.UnrealEdEngine_0:NS_GameInstance_C_17.w_POI_Label_C_17
    Function /Game/Widgets/POI/w_POI_Label.w_POI_Label_C:ExecuteUbergraph_w_POI_Label:0560
    PIE:Error: Error Blueprint Runtime Error: Accessed None trying to read property K2Node_DynamicCast_AsNS_Player_Controller from function: 'ExecuteUbergraph_w_POI_Label' from node: Branch in graph: EventGraph in object: w_POI_Label with description: Accessed None trying to read property K2Node_DynamicCast_AsNS_Player_Controller


    The same but with the cast converted to Pure:
    Click image for larger version

Name:	pure.PNG
Views:	1
Size:	83.0 KB
ID:	1213052

    Works fine and the log is clean. The whole thing is triggered by widget's onMouseLeave event.

    Any ideas why would the normal cast produce something bizarre like that. Or am I missing something obvious?

    #2
    It could be because you are also connecting the Failed pin into the Branch, which will try to still read the variable when the cast fails.

    Other than that /shrug
    Marketplace code plugin: AesTargeting - Make your Actors targetable =)

    Comment


      #3
      Originally posted by Aesais View Post
      It could be because you are also connecting the Failed pin into the Branch, which will try to still read the variable when the cast fails.

      Other than that /shrug
      Thanks. I had tried that; as I said above the Print node does not fire. :| Odd.

      Comment


        #4
        Looks like a bug to me.
        [Released] Multiplayer Combat Editor
        A-RPG Sacred Swords
        Auto-Chess Live Development
        Youtube Tutorials

        Comment


          #5
          It's in widgets - there are a ton of sneaky little issues in widgets, I suppose it's during the slate pass or something?

          Comment


            #6
            Originally posted by ste1nar View Post
            It's in widgets - there are a ton of sneaky little issues in widgets, I suppose it's during the slate pass or something?
            It's triggered by onMouseLeave event. I have generally avoided casting or any heavy lifting in widgets so this caught me by surprise. If I manage to isolate/reproduce this in a clean project, I'll put it up on answerhub. Thanks everyone.

            Comment


              #7
              Originally posted by Everynone View Post
              Thanks. I had tried that; as I said above the Print node does not fire. :| Odd.
              Do you mean by the picture that you posted, or did you disconnect the execution pin after the print string at a later time and retested?
              Marketplace code plugin: AesTargeting - Make your Actors targetable =)

              Comment


                #8
                I have tried half a dozen things by now, here's the best demo:

                Click image for larger version

Name:	Untitled.png
Views:	1
Size:	144.0 KB
ID:	1124736

                As you can see, the execution flow is fine and, most importantly, everything works as expected. The cast does not fail, the Print String does not fire. The output log throws the Accessed None error I mentioned in my initial post. Interestingly enough, the error is gone once this dynamic cast gets converted to its pure version. - that's the puzzling bit.

                It's not particularly bothersome, it's just quirky. Anyway, I'll shove it under the carpet for now. I find it hard to disagree with [MENTION=439973]ste1nar[/MENTION] at this point. :/

                Comment


                  #9
                  I can't tell you for sure without digging into the source code of how the two are implemented. But my guess is, the pure cast also has the same issue, it's just not throwing the warning because it's not really being executed (I think).
                  Whilst the non-pure one does throw the warning.

                  I think it's like dynamic- vs regular cast.
                  http://stackoverflow.com/questions/2...s-dynamic-cast

                  I think it's dynamic and regular? anyways I hope this helps you a bit even if it's a bit off.

                  Comment


                    #10
                    To elaborate a little bit on my previous statement, I remember when I used Unity years ago and working with that ui framework, I remember reading that every frame, the ui made two passes - the first time to calculate where everything should be and the second time actually drawing the elements. This meant that if I executed a variable ++ code, it would do that twice, so it would be like var+=2. It also resulted in a few other quirkyness, though I have no doubt that results from me not actually knowing much about the system.

                    Now, I don't really know how slate works. But I have come across several of these little "that should work... but doesn't" moments.
                    Here's an example - The relevant part in the linked post, for this topic, is the last picture showing the printed strings: https://forums.unrealengine.com/show...tially-working
                    Notice how the print string that verifies that the timer should clear is printed, but the timer is actually never cleared.
                    That problem has been worked around, it's just an example of how executing code through a widget event may have unexpected results.

                    Another thing I have noticed is that during a drag & drop event, the engine does not warn about "accessed none".
                    If you create a drag and drop event and a way to trigger it, now add an actor reference variable to the widget. But never set it. Inside the Drag & drop function you can now get and set variables of that empty variable, but as you print string: is valid(), it will print "false". Yet no warnings.

                    There are also a few situations where the only way to have something happen properly inside widgets, is by executing it on the next frame (for example using a "set timer by event" with a value of 0.00001).

                    I could go on, but it's either too specific, overkill because you've already gotten my point, or I have forgotten about them. I should start making a list.

                    Comment


                      #11
                      [MENTION=10333]Simple2012[/MENTION] & [MENTION=439973]ste1nar[/MENTION], thanks for your input on this. I understand pointers relatively well (even more so now after following the link) but the nuances of how blueprints pull certain behaviours off elude me at times.

                      Originally posted by ste1nar View Post
                      Another thing I have noticed is that during a drag & drop event, the engine does not warn about "accessed none".
                      If you create a drag and drop event and a way to trigger it, now add an actor reference variable to the widget. But never set it. Inside the Drag & drop function you can now get and set variables of that empty variable, but as you print string: is valid(), it will print "false". Yet no warnings.
                      Was not aware of this, sounds like a little debugging nightmare - will keep my eyes peeled for those.

                      Thanks again.

                      Comment


                        #12
                        Originally posted by Everynone View Post
                        I have tried half a dozen things by now, here's the best demo:

                        [ATTACH=CONFIG]133329[/ATTACH]

                        As you can see, the execution flow is fine and, most importantly, everything works as expected. The cast does not fail, the Print String does not fire. The output log throws the Accessed None error I mentioned in my initial post. Interestingly enough, the error is gone once this dynamic cast gets converted to its pure version. - that's the puzzling bit.

                        It's not particularly bothersome, it's just quirky. Anyway, I'll shove it under the carpet for now. I find it hard to disagree with [MENTION=439973]ste1nar[/MENTION] at this point. :/
                        Why do you still have the Cast Failed pin connected to the flow of execution? Disconnect the White Pin after the Print String and let me know if you still get these errors.
                        Marketplace code plugin: AesTargeting - Make your Actors targetable =)

                        Comment


                          #13
                          Originally posted by Aesais View Post
                          Why do you still have the Cast Failed pin connected to the flow of execution?
                          Debugging purposes - to see if the cast fails, to test the flow, to isolate the issue - that's what this pin is for (amongst other things)

                          Originally posted by Aesais View Post
                          Disconnect the White Pin after the Print String and let me know if you still get these errors.
                          Not sure why that would make any difference whatsoever. But just to humour myself, I did as suggested; same story, no dice.



                          If you are trying to understand what I mean, have a look at these; both work, but the top one throws Accesses None error:



                          The widget is very simple:
                          [root] (self hit test invisible)
                          [border] (shti)
                          [overlay] (shti)
                          [button] (visible)
                          [image] (hti)
                          [vBox] (hti)

                          The button is the only thing that is interactive here, also checked with with widget reflector.
                          And that's the only widget that exhibits this behaviour, tested with some other random ones and casting works fine.

                          Meh.
                          Attached Files
                          Last edited by Everynone; 03-16-2017, 05:09 AM.

                          Comment


                            #14
                            Well, unfortunately it didn't work, but when debugging you must remove any element that could be causing the error, especially when that element is incorrect code. I understand that you want a print string on cast failed, which is fine, but continuing the execution chain as if it succeeded is not good practice. In C++ using a null pointer would lead to an Editor crash =x.

                            My last idea is to replace the 'Get Player Controller' node with 'Get Owning Player', as this is the standard node to use in Widgets. Just be sure to set the Owning Player on the Create Widget node.
                            Last edited by Aesais; 03-16-2017, 10:13 AM.
                            Marketplace code plugin: AesTargeting - Make your Actors targetable =)

                            Comment

                            Working...
                            X