Segmentation fault when minimize window whit SDL 1.3

I’m Sorry for my poor English, I’m Italian and I never seriously learned your language. I Hope you can understand my problem:

This is my code:

Code:

#include <SDL/SDL.h>

#include
using std::cout;
using std::endl;

#include “printSDLVersion.h”

int main( int argc, char** argv )
{
SDL_Window* mainWindow = 0; // A pointer to SDL_Window
SDL_Surface* screen = 0; // A pointer to SDL_Surface
SDL_Surface* aImage = 0; // A pointer to SDL_Surface

printSDLVersion(); // Shown Linked and Compiled library version

if( SDL_Init( SDL_INIT_EVERYTHING ) )
{
cout << "Error: Impossible initialize SDL\n "
<< SDL_GetError() << endl;
return 1;
}

mainWindow = SDL_CreateWindow( “Test SDL”, 0, 0, 1280, 720,
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE );

if( !mainWindow )
{
cout << "Impossible creating the window\n "
<< SDL_GetError() << endl;

   return 1;
 }

screen = SDL_GetWindowSurface( mainWindow );
if( screen == NULL )
{
cout << “Impossible get the window surface\n”
<< SDL_GetError() << endl;
return 1;
}

aImage = SDL_LoadBMP( “./prova.bmp” );
if( aImage == NULL )
{
cout << “Impossible loading the image\n”
<< SDL_GetError() << endl;
return 1;
}

SDL_Surface* temp = 0; // temporary pointer
temp = SDL_ConvertSurface( aImage, screen->format, screen->flags);
if( temp == NULL )
  {
cout << " Impossible Converting Surface\n"
     << SDL_GetError() << endl;
return 1;
  }
SDL_FreeSurface( aImage );
aImage = temp;
    
SDL_Rect first = {0, 0, 400, 300};
SDL_Rect second = {400, 0, 400, 300};
SDL_Rect third = {0, 300, 400, 300};
SDL_Rect fourth = {400, 300, 400, 300};

for( bool running = true; running; )
{
SDL_Event anyEvent;
while( SDL_PollEvent( &anyEvent ) == 1 )
{
if( anyEvent.type == SDL_QUIT )
{
running = false;
}
}

   SDL_BlitSurface( aImage, NULL, screen, &first );
   SDL_BlitSurface( aImage, NULL, screen, &second );
   SDL_BlitSurface( aImage, NULL, screen, &third );
   SDL_BlitSurface( aImage, NULL, screen, &fourth );

   screen = SDL_GetWindowSurface( mainWindow ); // request from SDL_UpdateWindowSurface through SDL_GetError
   if( screen == NULL )
 {
   cout << "Impossible get the window surface\n"
            << SDL_GetError() << endl;
   return 1;
 }

   if( SDL_UpdateWindowSurface( mainWindow ) )
 {
   cout << "Impossible Updating Window Surface\n"
	<< SDL_GetError() << endl;

   return 1; 
 }
     
 }  

SDL_FreeSurface( aImage );
SDL_DestroyWindow( mainWindow );
SDL_Quit();
return 0;
}

Why when I click on minimize window, the program give me a segmentation fault error ?

Why SDL_UpdateWindowSurface request to get a new window surface, through SDL_GetError() ?

The program running in a Debian Squeeze OS, Gnome Desktop Environment and nvidia proprietary driver.

The current version of SDL is the last one in mercurial repository of the 1.3 branch.

In the end I understand which the origin of my problems is the window effects.

I don’t know anything about debian but sdl I know. I don’t see you looking
for the event of minimize and then doing something with it.On Tue, Dec 6, 2011 at 9:40 AM, bigdavid85 wrote:

**
I’m Sorry for my poor English, I’m Italian and I never seriously learned
your language. I Hope you can understand my problem:

This is my code:

Code:

#include **

#include **
using std::cout;
using std::endl;

#include “printSDLVersion.h”

int main( int argc, char** argv )
{
SDL_Window* mainWindow = 0; // A pointer to SDL_Window
SDL_Surface* screen = 0; // A pointer to SDL_Surface
SDL_Surface* aImage = 0; // A pointer to SDL_Surface

printSDLVersion(); // Shown Linked and Compiled library version

if( SDL_Init( SDL_INIT_EVERYTHING ) )
{
cout << "Error: Impossible initialize SDL\n "
<< SDL_GetError() << endl;
return 1;
}

mainWindow = SDL_CreateWindow( “Test SDL”, 0, 0, 1280, 720,
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE );

if( !mainWindow )
{
cout << "Impossible creating the window\n "
<< SDL_GetError() << endl;

   return 1;
 }

screen = SDL_GetWindowSurface( mainWindow );
if( screen == NULL )
{
cout << “Impossible get the window surface\n”
<< SDL_GetError() << endl;
return 1;
}

aImage = SDL_LoadBMP( “./prova.bmp” );
if( aImage == NULL )
{
cout << “Impossible loading the image\n”
<< SDL_GetError() << endl;
return 1;
}

SDL_Surface* temp = 0; // temporary pointer
temp = SDL_ConvertSurface( aImage, screen->format, screen->flags);
if( temp == NULL )
  {

cout << " Impossible Converting Surface\n"
<< SDL_GetError() << endl;
return 1;
}
SDL_FreeSurface( aImage );
aImage = temp;

SDL_Rect first = {0, 0, 400, 300};
SDL_Rect second = {400, 0, 400, 300};
SDL_Rect third = {0, 300, 400, 300};
SDL_Rect fourth = {400, 300, 400, 300};

for( bool running = true; running; )
{
SDL_Event anyEvent;
while( SDL_PollEvent( &anyEvent ) == 1 )
{
if( anyEvent.type == SDL_QUIT )
{
running = false;
}
}

   SDL_BlitSurface( aImage, NULL, screen, &first );
   SDL_BlitSurface( aImage, NULL, screen, &second );
   SDL_BlitSurface( aImage, NULL, screen, &third );
   SDL_BlitSurface( aImage, NULL, screen, &fourth );

   screen = SDL_GetWindowSurface( mainWindow ); // request from

SDL_UpdateWindowSurface through SDL_GetError
if( screen == NULL )
{
cout << “Impossible get the window surface\n”
<< SDL_GetError() << endl;
return 1;
}

   if( SDL_UpdateWindowSurface( mainWindow ) )
{
  cout << "Impossible Updating Window Surface\n"
  << SDL_GetError() << endl;

  return 1;
}

 }

SDL_FreeSurface( aImage );
SDL_DestroyWindow( mainWindow );
SDL_Quit();
return 0;
}

Why when I click on minimize window, the program give me a segmentation
fault error ?

Why SDL_UpdateWindowSurface request to get a new window surface, through
SDL_GetError() ?

The program running in a Debian Squeeze OS, Gnome Desktop Environment and
nvidia proprietary driver.

The current version of SDL is the last one in mercurial repository of the
1.3 branch.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org