Results 1 to 6 of 6

Thread: Self Terminate an App

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Self Terminate an App

    Alright, my Dx7 engine checks for and inits certain interfaces in its constructor.
    If I cannot create a certain one it shows a messagebox saying it cannot find it.

    I want at that point to terminate the application, a proper terminate, all memory gone and such. So how do I terminate an app within a class's constructor?

    I will know nothing, no hwnd, no thread, no hinstance.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I guess you have to send the info to the constructor, or you have to write a try catch block around the lines that makes the object.

  3. #3

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339
    Hmmmm...Well...
    Would that work in the case of DX?
    If it fails in initializing it only returns a simple value saying it failed, does it flag an error on the system to?

    try
    {
    //code
    }

    i aint sure how to work a try catch...can u give example
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Not sure if I am getting you. Making the DX object is the first thing that you do. So there isn't actualy anything to clean up. So something like this is pretty normal to do.



    Code:
        CMyD3DApplication d3dApp;
    
        if( FAILED( d3dApp.Create( hInst ) ) )
            return 0;

  5. #5

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339
    yah, except the constructor cannot return anything.

    When my dx7 engine constructs I want it to interface to DD, D3D...if it fails I want the program to exit and let the user know wut happened.

    I guess the easy resolve would be to take the init out of the constructor.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    So create your special object on the heap:
    Code:
    boost::shared_ptr<MyDXWrapper> dx;
    try {
      dx.reset(new MyDXWrapper);
    } catch(const std::exception &e) {
      // Init failed
      return 1;
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width