Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Access Violation Error During OnRender()

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

    Access Violation Error During OnRender()

    Hi,

    I am using RenderTarget.DrawGeometry() in my indicator to paint a custom shape in OnRender(). Works great and no problem. Today I added a method to draw text using RenderTarget.DrawTextLayout() and I am getting Access Violation errors relating to writing to protected memory. Huh?

    Is this a device context issue or a factory issue or something altogether that I am missing? If I get rid of the text writing method, all is good. The moment I add the text writing method, I get the error. I call the text method from inside the shape drawing method during OnRender().

    Any suggestions how to debug this would be greatly appreciated. Thank you.

    EDIT: I wonder if this occurs because I have multiple Render targets: the shape and the text.How should I handle multiple Render targets?
    Last edited by Zeos6; 05-16-2018, 03:37 PM.

    #2
    Hello Zeos6,

    I have an example of rendering text with DrawTextLayout().
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply ChelseaB. Unfortunately your reply does not address my question. I know how to render text with DrawTextLayout() and I know how to render shapes with RenderTarget.DrawGeometry(). The problem I am having is as follows...

      1. I render a shape using RenderTarget.DrawGeometry().
      2. I try to render text with DrawTextLayout()

      It is on this step 2 that I get the access violation error.
      I can do step 1 alone and I can do step 2 alone. How do I do them in combination when step 1 calls the method of step 2?

      EDIT: I am starting to think that this is RenderTarget issue as there are multiple targets.
      Last edited by Zeos6; 05-16-2018, 04:30 PM.

      Comment


        #4
        Hello Zeos6,

        Without seeing the code its hard to say whats wrong..

        It might be a brush that's not being reconstructed in OnRenderTargetChanged().

        There will only be one RenderTarget at a time, but this does get destroyed and recreated throughout the life of the chart.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi ChelseaB,

          Thank you for the reply. I think you are correct in that it likely deals with a brush and/or a stroke not being reconstructed during OnRenderTargetChanged(). Do you have a sample code snippet that reconstructs a brush and a stroke during OnRenderTargetChanged()? I have been playing with this for two days now and just seem to be missing something.Thank you.

          EDIT: Figured it out. Thanks ChelseaB. Was disposing a brush needed in step 1 in the method of step 2.Once I corrected this, everything works fine now.
          Last edited by Zeos6; 05-17-2018, 10:46 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          2 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          470 views
          0 likes
          Last Post tradingnasdaqprueba  
          Started by aa731, Today, 02:54 AM
          0 responses
          4 views
          0 likes
          Last Post aa731
          by aa731
           
          Started by Christopher_R, Today, 12:29 AM
          0 responses
          10 views
          0 likes
          Last Post Christopher_R  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          166 responses
          2,237 views
          0 likes
          Last Post sidlercom80  
          Working...
          X