Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TreeTree

Pages: [1]
1
DotNet / TGUI System Access Violation
« on: April 05, 2014, 02:06:32 am »
So I just tried the TGUI for .NET and the example on this page http://tgui.net/example-code/csharp-login-screen/index.html. It does work exactly like I expect it would but there is a problem.

When I close the window using the Window.Close function and the program ends completely, I get a

Code: [Select]
A first chance exception of type 'System.AccessViolationException' occurred in sfmlnet-graphics-2.dll
An unhandled exception of type 'System.AccessViolationException' occurred in sfmlnet-graphics-2.dll

sfmlnet-graphics-2.dll!SFML.Graphics.Context.Context()
sfmlnet-graphics-2.dll!SFML.Graphics.Context.Global.get()
sfmlnet-graphics-2.dll!SFML.Graphics.Texture.Destroy(bool disposing)
sfmlnet-window-2.dll!SFML.ObjectBase.Dispose(bool disposing)
sfmlnet-window-2.dll!SFML.ObjectBase.Finalize()
The way I understand it is this error occurs when I create a resource and forget to call Dispose () on it like with a RenderTexture object. This still happens after I dispose the Window and the GUI object.

So I'm wondering if this may be something specific to me and how I've set up the project, because it would be strange if this was a common bug and the developer didn't catch it.

Any thoughts?

2
I see, so I'll need to save a copy of the ball somewhere during the if {}. I changed the vector to a non-pointer type and used references to edit individual sprites like the paddle. This is all slightly strange to me, I came from a ActionScript background and doing the above has no issues.

3
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <vector>

using namespace std;
using namespace sf;

Sprite CreateBall (Image img, Vector2f coords) {
        Sprite ball (img);
        ball.SetPosition (coords);
        return ball;
}

int main () {
        RenderWindow window (VideoMode (500, 500, 32), "Squash", Style::Close);
        window.SetFramerateLimit (30);

        Image imgPaddle;
        imgPaddle.LoadFromFile ("paddle.png");
        Sprite paddle (imgPaddle);
        paddle.SetCenter (paddle.GetSize ().x / 2, 0);

        Image imgBall;
        imgBall.LoadFromFile ("ball.png");
       
        vector <Sprite*> sprites;
        sprites.push_back (&paddle);

        int frame = 0;
        bool running = true;

        while (running) {
                Event theEvent;

                while (window.GetEvent (theEvent)) {
                       
                }
               
                if (frame % 30 == 0) {
                        Sprite ball = CreateBall (imgBall, Vector2f (window.GetWidth () / 2, window.GetHeight () / 2));
                        sprites.push_back (&ball);
                }

                frame++;

                window.Clear ();
               
                for (int i = 0; i < sprites.size (); i++) {
                        window.Draw (*sprites [i]);
                }

                window.Display ();
        }

        return 0;
}
 
The error doesn't occur when I comment out window.Draw. Also if I stop the loop from adding more balls to the vector and instead I add one before the loop starts, it works.

All I know about this error is that I'm trying to call a virtual function from an abstract class or something like that and I don't really know how that is my case.

Pages: [1]
anything