Compile and crash

About Monkey 2 Forums Monkey 2 Programming Help Compile and crash

This topic contains 6 replies, has 3 voices, and was last updated by  wiebow 2 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #986

    wiebow
    Participant

    Sorry Mark, I have another one. This code results in a compile error, but the application starts anyway, and I need to kill the process:

    This is the output from mx2cc:

    Parsing…
    Semanting…
    Translating…
    Compiling….
    Linking /home/wiebo/Monkey2Stuff/boulderdash/bd.buildv009/desktop_debug_linux/bd
    Running /home/wiebo/Monkey2Stuff/boulderdash/bd.buildv009/desktop_debug_linux/bd

    Memory access violation
    {{!DEBUG!}}
    >Font:Void(font:mojo.graphics.Font);/home/wiebo/Monkey2/modules/mojo/graphics/canvas.monkey2;1110018;4431205
    font:mojo.graphics.Font=@0x1848420
    >new:Void();/home/wiebo/Monkey2Stuff/boulderdash/bd.monkey2;110594;3342060
    >Main:Void();/home/wiebo/Monkey2Stuff/boulderdash/bd.monkey2;147457;89

    When I remove the canvas:Canvas field from the Class, the program compiles, but ofcourse it does not work. I was trying this to see if I can get to the canvas in the window.  Still no luck 🙂

    After killing the application I get the rest of the output:

    ***** Fatal mx2cc error *****

    Build error.
    :build_project_debug FAILED

    BUILD FAILED

    FAILURE: Build failed with an exception.

    * Where:
    Build file ‘/home/wiebo/Monkey2Stuff/boulderdash/build.gradle’ line: 16

    * What went wrong:
    Execution failed for task ‘:build_project_debug’.
    > Build project failed with exit code: 255

    * Try:
    Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.

    Total time: 23.415 secs
    [Finished in 23.8s with exit code 1]

    #999

    Danilo
    Participant

    wiebow:
    Your ‘Field canvas:Canvas’ is not initialized by using ‘New’
    or a getter function/method. Means ‘canvas’ is Null, and you
    write to canvas.Font

    If ‘i = Image.Load()’ returns Null, accessing ‘i.Handle’ would
    also crash (at least if they are Classes, not so with Structs).

    #1000

    Danilo
    Participant

    Try something like this…

     

    #1001

    Mark Sibly
    Keymaster

    Sorry Mark, I have another one.

    No problem – I want to get the bugs out ASAP.

    It is actually working as expected though. The program successfully compiles and runs but generates a ‘memory access violation’ due to the null pointer, so it’s not the compiler crashing at least. And on the 97% finished version of Ted2 I’ve got running here, the debugger pops up and you can actually see where the error is – what luxury!

    When I remove the canvas:Canvas field from the Class, the program compiles

    Doesn’t here – I get ‘identifier canvas not found’ (as I would have expected).

    I was trying this to see if I can get to the canvas in the window.

    You can’t. The render canvas is ‘special’, and I want to make sure it’s state is not changed behind my back, and that I can change it on the fly if necessary (ie: you may not always get the same canvas in ‘OnRender’) for future features.

    You can always render to an ‘image canvas’ and just DrawImage that to the render canvas in OnRender. This allows you to ‘draw’ at any time, and to apply funky effects at OnRender time like fade out etc. I’ll probably end up adding a CanvasView that does just that eventually, but the whole view system needs cleaning up and doccing before that’s realistic, so that’s an after V1.0 thing.

     

     

     

     

     

    #1002

    Danilo
    Participant

    Mark Sibly wrote:

    You can’t. The render canvas is ‘special’, and I want to make sure it’s state is not changed behind my back, and that I can change it on the fly if necessary (ie: you may not always get the same canvas in ‘OnRender’) for future features.

    So, if the canvas doesn’t preserve all states, it would be:

    #1003

    Mark Sibly
    Keymaster

    That’d work.

    Also, not sure if it’s docced yet but each view also has a ‘Style’ object that has DefaultColor and DefaultFont properties. These are set just before OnRender is called, so you can provide a default font and color for OnRender, eg:

     

     

    #1005

    wiebow
    Participant

    This makes sense now. Thanks.   The inner workings of Monkey 2 and mojo are most interesting to explore 🙂

    @Mark: Oh that default style looks interesting. I’ll go dive into the style code. Thanks.

    @Danillo: Thanks for the tip about setting the font in the render method. It’s something I can live with!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.