[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2779
  • Last Modified:

SDL + MFC

Hi guys,

i have an MFC application, which has a main window and in this window i have a button which opens another dialog (lets call it SDL dialog) to display a SDL simulation.

i have created the SDL dialog which the SDL window must run inside ...

it works BUT when i close the SDL dialog and simulate again....after the second or the third time, the whole application quits ith an error message :"....exe  has exited with code -1073741819 (0xC0000005)."

i guess its related to how things exit...i mean the momory is not freed correctly....

here is a piece of code:

in the main dialog Simulate button:
void CLEDart_MFC_SDLDlg::OnSimulate()
{
      SDLDialog = new CDialog;
      SDLDialog->Create(IDD_DIALOG_SDL, this);

      HWND dlgHandle = SDLDialog->GetSafeHwnd();

      SDLDialog->ShowWindow(SW_SHOW);

      CSimulationScreen *simulationScreen;
      simulationScreen = new CSimulationScreen;

      simulationScreen->InitializeSDL((int) dlgHandle ); //its initialize and run together

      delete simulationScreen;
      delete SDLDialog;
}
void CSimulationScreen::InitializeSDL(int hWnd)
{
//now in the simulationscreen class
      char SDL_vidvar[256];
      sprintf(SDL_vidvar, "SDL_WINDOWID=%d", hWnd);
      _putenv(SDL_vidvar);

      if(SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE  ) < 0)
      {
            return;
      }

      m_CScreenSurface = SDL_SetVideoMode(m_iScreenWidth, m_iScreenHeight,
            COLOR_DEPTH, SDL_HWSURFACE | SDL_DOUBLEBUF);

      if(m_CScreenSurface == NULL)
      {
            return;
      }

               ///THEN RUN
               //Run();
}

CSimulationScreen::~CSimulationScreen()
{
      SDL_FreeSurface(m_CScreenSurface);
      SDL_Quit();
}


any idea where i can be wrong ...or how to initialize/ quit things correctly...

thanx
0
aluay
Asked:
aluay
  • 5
  • 2
  • 2
  • +1
2 Solutions
 
Jose ParrotGraphics ExpertCommented:
Hi,

Stupid suggestion, but can't resist to tell you..
Dou you have Rosetta or BOINC stuff installed in your PC?
Lot of people has this error message with BOINC around.
Solution is upgrade to last version.
http://boinc.berkeley.edu/

Jose

0
 
aluayAuthor Commented:
hi JoseParrot,
no...

my simulation has nothing to do with sound, and i dont have any of these installed

but thanx anyway
0
 
gran88Commented:
To start with, some good debugging practice would be to have return integers for each of your subroutines to help identify where the problem exists, along with an error message.

As far as I can tell, the SDL code is flawless.  You call the constructor, initialize SDL, open up the screen, close the screen, and call the destructor.  The SDL initializes, starts a screen........ You might be running into problems with SDL trying to grab and set the video mode from MFC.  Considering they both do the same thing, you're going to be running into many many conflicts.  Choose one or the other, they overlap.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jose ParrotGraphics ExpertCommented:
Hi,

Returning to SDL question.

When destroying CSimulationScreen, the SDQ_Quit is invoked. This shutdown the entire SDL environment.

If you have concurrent SQL runings, you must initialize and quit each one in separate, by using SubSystem scope. So, should invoke:

____________________________________________________________
SDL_Init          in a "global" approach
   SDL_InitSubSystem       as a limited scope one
   SDL_QuitSubSystem      to end only this run
SDL_Quit         to end all SDL stuff
____________________________________________________________


Let's an example.
____________________________________________________________
SDL_Init(SDL_INIT_VIDEO);    <--- SDL starts, initializing video
     :
SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF|SDL_FULLSCREEN);
     :
SDL_InitSubSystem(SDL_INIT_JOYSTICK);  <--- to initialize only the joystick
     :
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);  <--- to quit only the joystick
     :                               <--- any code with video. SDL video is still live
SDL_Quit();                     <-- now we have SDL anymore
____________________________________________________________

Sounds the problem arises due invoking a SDL subsystem when we have already quit the entire SDL.

Jose
0
 
aluayAuthor Commented:
Hi there,
no one answered my question.

i aquire refunding

thanx
0
 
VenabiliCommented:
Let me see if I understand what's up here:
- YOu received two good comments which can work if you work with them from two different experts who volunteer their time to help you
- You decided to ignore them and not to post even a single word
- You want a refund?!?!

Sorry - but this is a collaborative site and you are supposed to work with the experts. You  had chosen not to. IF nothing had really helped, I am not opposed to delete - NO REFUND. But a refund will be an insult to anyone that try to help you while you aparently do not even bother to say thanks or to respond somehow....
0
 
aluayAuthor Commented:
you added a comment if any one objects and i did,
i didnt ignore but simply i was & am waiting for an answer
0
 
aluayAuthor Commented:
you can delete it or keep it..simply its an answered question with all appreciation to the people who trie to help
0
 
VenabiliCommented:
If something is not working, you MUST tell so. If you ignore an expert comment, even if someone knows the answer, they won't post it. You ignored both the comments above the cleanup one and you STILL ignore them.
0
 
aluayAuthor Commented:
what can i say, the guys thankfully are trying to help...the first answer is a suggestion of a normal procedure, and the second, is providing a personal code, with SQL, and i dont have nything to do with SQL in my app. any way i dont understnad your attitude, and since your are the person responsible, just do what ever you want with the question.

BOTTOM line, the question was not answered.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now