- SFG_Window *window;
- SFG_Menu *from;
- SFG_MenuEntry *entry;
-
- assert( menu != NULL );
- freeglut_assert_ready;
-
- /*
- * First of all, have all references to this menu removed from all windows:
- */
- for( window = (SFG_Window *)fgStructure.Windows.First;
- window;
- window = (SFG_Window *)window->Node.Next )
- fghRemoveMenuFromWindow( window, menu );
-
- /*
- * Now proceed with removing menu entries that lead to this menu
- */
- for( from = (SFG_Menu *)fgStructure.Menus.First;
- from;
- from = (SFG_Menu *)from->Node.Next )
- fghRemoveMenuFromMenu( from, menu );
-
- /*
- * If the programmer defined a destroy callback, call it
- * A. Donev: But first make this the active menu
- */
- if ( menu->Destroy != NULL )
- {
- SFG_Menu *activeMenu=fgStructure.Menu;
- fgStructure.Menu = menu;
- menu->Destroy () ;
- fgStructure.Menu = activeMenu;
- }
-
- /*
- * Now we are pretty sure the menu is not used anywhere
- * and that we can remove all of its entries
- */
- while( (entry = (SFG_MenuEntry *)menu->Entries.First) != NULL )
- {
- fgListRemove(&menu->Entries, &entry->Node);
-
- if( entry->Text )
- free( entry->Text );
- entry->Text = NULL;
-
- free( entry );
- entry = NULL;
- }
-
- if ( fgStructure.Window == menu->Window )
- fgSetWindow ( menu->ParentWindow ) ;
- fgDestroyWindow ( menu->Window, TRUE ) ;
- fgListRemove( &fgStructure.Menus, &menu->Node );
- if( fgStructure.Menu == menu )
- fgStructure.Menu = NULL;
-
- free( menu );
+ SFG_Window *window;
+ SFG_Menu *from;
+ SFG_MenuEntry *entry;
+
+ assert( menu );
+ freeglut_assert_ready;
+
+ /*
+ * First of all, have all references to this menu removed from all windows:
+ */
+ for( window = (SFG_Window *)fgStructure.Windows.First;
+ window;
+ window = (SFG_Window *)window->Node.Next )
+ fghRemoveMenuFromWindow( window, menu );
+
+ /*
+ * Now proceed with removing menu entries that lead to this menu
+ */
+ for( from = ( SFG_Menu * )fgStructure.Menus.First;
+ from;
+ from = ( SFG_Menu * )from->Node.Next )
+ fghRemoveMenuFromMenu( from, menu );
+
+ /*
+ * If the programmer defined a destroy callback, call it
+ * A. Donev: But first make this the active menu
+ */
+ if( menu->Destroy )
+ {
+ SFG_Menu *activeMenu=fgStructure.Menu;
+ fgStructure.Menu = menu;
+ menu->Destroy( );
+ fgStructure.Menu = activeMenu;
+ }
+
+ /*
+ * Now we are pretty sure the menu is not used anywhere
+ * and that we can remove all of its entries
+ */
+ while( entry = ( SFG_MenuEntry * )menu->Entries.First )
+ {
+ fgListRemove( &menu->Entries, &entry->Node );
+
+ if( entry->Text )
+ free( entry->Text );
+ entry->Text = NULL;
+
+ free( entry );
+ entry = NULL;
+ }
+
+ if( fgStructure.Window == menu->Window )
+ fgSetWindow( menu->ParentWindow );
+ fgDestroyWindow( menu->Window, TRUE );
+ fgListRemove( &fgStructure.Menus, &menu->Node );
+ if( fgStructure.Menu == menu )
+ fgStructure.Menu = NULL;
+
+ free( menu );