Jump to content
Sign in to follow this  
Guest Patrick_Waugh

FSX SP1 Bug? Localized cause of CTD

Recommended Posts

Guest Patrick_Waugh

After 8 solid hours of testing and pulling out my hair, I have finally localized the cause of the CTD when loading the default B206 (and only the B206) after my aircraft.In my fuel valve gauge on the main panel, I define an event handlerCODE

void CALLBACK EventHandler (ID32 event, UINT32 evdata, PVOID userdata){	if (event == KEY_PAUSE_TOGGLE)	{		// User has PAUSED the sim		bPauseToggle = !bPauseToggle;	}	if (event == KEY_SOUND_TOGGLE)	{		// User has toggled sound		bSoundToggle = !bSoundToggle;	}}void CALLBACK C_GAUGE(Gcb_)(PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data){  PCHAR	pParams		= NULL;  switch (service_id)  {    case PANEL_SERVICE_PRE_INITIALIZE:      if ( pgauge != NULL )      {	register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, 0);    case PANEL_SERVICE_PRE_KILL:      unregister_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, 0);      break;}
And when I comment out the handler and the register and unregister calls, FSX does not crash.Anyone have any suggestions? Does this sound like a bug since the code did work? Or, do you see something I'm doing wrong here?Patrick

Share this post


Link to post
Share on other sites

Try moving the register event to PANEL_SERVICE_CONNECT_TO_WINDOW, and the unregister event to PANEL_SERVICE_DISCONNECT. Alternatively, put them in module_init and module_deinit.PRE_INITIALIZE and PRE_KILL get executed when the user switches between windowed and full-screen, and when the user moves or re-sizes a panel window.Doug

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Doug,>Try moving the register event to>PANEL_SERVICE_CONNECT_TO_WINDOW, and the unregister event to>PANEL_SERVICE_DISCONNECT. OMG, you are a genius! It worked!!!! Why?>Alternatively, put them in module_init and module_deinit.I will try this too see if this works too, but I'm guessing it will given your suggestion.>PRE_INITIALIZE and PRE_KILL get executed when the user>switches between windowed and full-screen, and when the user>moves or re-sizes a panel window.Ok, I open FS in a window (vs. full screen) switch from VC to 2D view, then switch to the default, and it locks up. There was never a window resize, or window move. However, it did not lock until I clicked the window, so maybe that triggered the pair.You must have spent hours analyzing when those get called.May you win the lottery this coming weekend!Patrick

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

I spoke to soon :(Basically, moving the registration allows other aircraft to be loaded, but the Event Handler is never called.Also, if fact, if done the other way, ALL other aircraft crash after being loaded, not just the default B206 as I originally thought.Moving it to the module_init etc. also compiles, but again the handler is never actually called, although loading of other aircraft does not cause a crash.So, not sure what to try now.Patrick

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Finally solved this one totally.The secret was using: PANEL_SERVICE_PANEL_OPEN PANEL_SERVICE_PANEL_CLOSEimagine that.

Share this post


Link to post
Share on other sites

I'm happy you got it sorted out.There are so MANY of the PANEL_SERVICE_xxx cases and not a single one of 'em is actually explained anywhere in the SDK, so we all have to work on the "Principle of Guess and by God..." *:-* "Every rule ever made has at least as many exceptions as there are people living..." :)


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Yes, it was not apparent even from looking at the order they are called when different events happen in the sim.But, it seems they are making more sense to me now. It really would be nice if they were documented somewhat.Patrick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...