Full screen change problem

Hi all,
I’ve faced problem.
I can change from window mode to full screen mode.
but I can not change full screen to window mode.
Follow code is my code.
I met a error message like this.

Xlib: unexpected async reply (sequence 0x8f)!
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 12 (X_ConfigureWindow)
Resource id in failed request: 0x2a0000d
Serial number of failed request: 154
Current serial number in output stream: 157

give me some advide.

Tnanks-------------------------------------------------------------------------------
if(screen_change){
pthread_mutex_lock(&wait_mutex);

        if(full_screen){
            SDL_FreeSurface(sdlScreen);

	// video_width_wm :current X11 width
	// video_heidht_wm : current X11 hegiht
                                                                           
                                                  
            l_sdlRect.w = video_width_wm;            
            l_sdlRect.h = (video_width_wm*video_height)/video_width;
            l_sdlRect.x = 0;
            l_sdlRect.y = (video_height_wm - l_sdlRect.h)/2;
                                                                           
                                                                           
                                                                           
                         
            sdlScreen = SDL_SetVideoMode(video_width_wm, video_height_wm,

32, SDL_HWSURFACE|SDL_FULLSCREEN);
SDL_DisplayYUVOverlay(l_sdlOverlay, &l_sdlRect);

        }else{
            SDL_FreeSurface(sdlScreen);
                                                  
	// video_width : video width
	// video_height : video height
                                                                            
            l_sdlRect.x = 0;
            l_sdlRect.y = 0;
            l_sdlRect.w = video_width;
            l_sdlRect.h = video_height;
                                                                           
                                                  
            sdlScreen = SDL_SetVideoMode(video_width, video_height, 32,

SDL_HWSURFACE);
SDL_DisplayYUVOverlay(l_sdlOverlay, &l_sdlRect);

        }
                                                                           
                                                  
        screen_change = 0;
        pthread_mutex_unlock(&wait_mutex);
    }

John wrote:

            SDL_FreeSurface(sdlScreen);

Don’t ever do that.–
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com