Results 1 to 9 of 9

Thread: Throw exception within ClanLib app is not working properly

  1. #1
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default Throw exception within ClanLib app is not working properly

    Its not possible to throw any exception within ClanLib app, if thrown it crashes with Access Violation. How can I throw exception without this problem? I tried throwing CL_Error to see if its working, but its not working either. And even if I just include core.h in one of my classes the app will crash at the end when quitting normally.

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    It should be possible to throw any exception with ClanLib 0.8 and 0.9

    It sounds like one of the class destructors is getting confused (in your app or in clanlib itself)

    Try throwing an exception in the main loop of the Basic2D example

  3. #3
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    Throwing in the main loop is not a problem, it works.

    Here is the list of problems:

    1. Throwing in any class that is not within main loop crashes the app without catch
    2. If throwing CL_Error within class that is not related to ClanLib, it catches the exception, but crashes at the last core's destructor
    3. If you just include "ClanLib/core.h" in class that has nothing to do with ClanLib, it crashes the app at the core's destructor.

    Ok, maybe I could avoid throwing exceptions and just display the message to the console.

    Can't you replicate this? I'm using windows MinGW compiled version.

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I can't replicate this, it seems to work with ClanLib 0.9 (i don't use 0.8)

    You have catched the thrown exception?

  5. #5
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    Only when throwing CL_Error it gets catched before crashing.

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I am confused, maybe you can send an example.

    I mean.

    class myclass
    {
    public: myclass() {}
    };

    void func()
    {
    throw myclass();
    }

    void loop()
    {
    func()
    catch myclass
    {
    should get here
    }
    }

    (Without catch myclass, if would crash with an unhandled exception - afaik)

  7. #7
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Right, what rombust said. So if you want to handle more exception types, you would something like:
    Code:
    try {
    
    //do stuff that throws an exception, like throw CL_Error("Oh crap");
    
    }
    catch(CL_Error error)
    {
    	std::cout << "CL_Error Exception caught : " << error.message << std::endl;	
    }
    
    catch (int param)
    {
    	std::cout << "Int Exception caught : " << param << std::endl;			
    }
    
    catch (...)
    {
    	std::cout << "Unknown Exception caught : " << std::endl;	
    }
    Seth A. Robinson
    Robinson Technologies

  8. #8
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    CL_Error is catched in main loop:

    try {

    //do stuff

    } catch( CL_Error err ) {

    }

    Like it should be in your tutorial.

    Now try to throw CL_Error within some class that has nothing to do with ClanLib, but your application. And even if I do not throw, but just include "ClanLib/core.h" because that's where CL_Error is, it will crash when last core's destructor is called.

    To make things strange, it does not crash all the time, but when it does it crashes with "Access Violation" ntdll.dll something like this.

  9. #9
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Hmm, maybe something with the MinGW compiler settings? I haven't had any problems like this with Visual C++.

    I had some sort of similar issues with exceptions not working in OSX until I disabled "Symbols Hidden By Default" (a gcc setting.. dunno if MinGW has similar stuff.).
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. CL_FramerateCounter.set_fps_limit() not working properly, need assistance
    By alexv1 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 02-18-2009, 04:56 PM
  2. Not a valid XML resource file exception
    By alexv1 in forum Official ClanLib SDK Forums
    Replies: 7
    Last Post: 02-06-2009, 11:30 PM
  3. some patches - std::exception, cl_vector, ostream, etc
    By logixoul in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 07-07-2008, 04:05 PM
  4. Have CL_Error inherit from std::exception
    By SnT2k in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 06-24-2008, 06:57 AM
  5. Exception every time I try to move stuff
    By cpury in forum Novashell Game Creation System
    Replies: 9
    Last Post: 03-01-2007, 11:26 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •