[SFML 2.1] Zacinanie sie programu przy próbie wczytania sf::Texture( 50% przypadków)
Ostatnio zmodyfikowano 2014-07-01 11:41
| colorgreen19 Temat założony przez niniejszego użytkownika | [SFML 2.1] Zacinanie sie programu przy próbie wczytania sf::Texture( 50% przypadków) » 2014-06-30 17:00:55 class TextureManager{
 public:
 TextureManager();
 ~TextureManager();
 
 typedef map < string, Texture * > mapT;
 
 
 static void LoadTexture( const string name, const string filename );
 static void EraseTexture( const string name );
 
 
 static Texture * GetT( const string tname );
 
 static mapT & GetTexture();
 
 static void CoutTextures()
 {
 for( auto i = Textures.begin(); i != Textures.end(); i++ )
 {
 cout << i->first << endl;
 }
 }
 protected:
 private:
 static mapT Textures;
 };
 
TextureManager::mapT TextureManager::Textures;
 TextureManager::TextureManager()
 {
 cout << "\tCONSTRUCTOR: TextureManager" << endl;
 }
 
 TextureManager::~TextureManager()
 {
 for( auto i = Textures.begin(); i != Textures.end(); i++ )
 {
 delete i->second;
 }
 }
 
 void TextureManager::LoadTexture( const string name, const string filename )
 {
 Texture * t = new Texture;
 if( !t->loadFromFile( filename.c_str() ) )
 {
 cout << "Couldnot load texture \"" << filename << "\"" << endl;
 return;
 }
 else cout << "Texture loaded \"" << filename << "\"" << endl;
 
 Textures[ name ] = t;
 }
 
 void TextureManager::EraseTexture( const string name )
 {
 delete Textures[ name ];
 Textures.erase( name );
 }
 
 Texture * TextureManager::GetT( const string tname )
 {
 cout << "TextureManager found... " << tname << endl;
 return Textures[ tname.c_str() ];
 }
 
 TextureManager::mapT & TextureManager::GetTexture()
 {
 return Textures;
 }
 
Logi z konsoli Core_Start()
 Core_Loading()
 CONSTRUCTOR: Settings
 Settings_LoadSettings()
 WindowX: 1600
 WindowY: 900
 Fullscreen: false
 Language: PL
 DESTRUCTOR: Settings
 Core_MainLoop()
 CONSTRUCTOR: Callback
 Decoder_DecodeState()
 Decoder_MainMenuShowing()
 CONSTRUCTOR: Callback
 CONSTRUCTOR: MainMenu
 Texture loaded "Files/tex/GUI_Button_Menu.png"
 CONSTRUCTOR: Widget
 CONSTRUCTOR: Button
 TextureManager found... GUI_Button_MainMenu
 CONSTRUCTOR: Widget
 CONSTRUCTOR: Button
 TextureManager found... GUI_Button_MainMenu
 CONSTRUCTOR: Widget
 CONSTRUCTOR: Button
 TextureManager found... GUI_Button_MainMenu
 DESTRUCTOR: Widget
 DESTRUCTOR: Widget
 DESTRUCTOR: Widget
 DESTRUCTOR: MainMenu
 DESTRUCTOR: Callback
 Decoder_DecodeState()
 Decoder_Playing()
 CONSTRUCTOR: Callback
 CONSTRUCTOR: Manager
 CONSTRUCTOR: Widget
 CONSTRUCTOR: Button
 CONSTRUCTOR: Editbox
 CONSTRUCTOR: Widget
 CONSTRUCTOR: Widget
 CONSTRUCTOR: Game
 Game_Show();
 CONSTRUCTOR: Map
 Map::LoadStage( filename, texfilename, tilesize);
 
 Map COLUMNS 84   Map ROWS 27
 Map::Load( tileset, int tileSize, int* tiles, width, height);
 Map Loaded
 Texture loaded "Files/tex/GUI_Palete_Character_Info.png"
 Texture loaded "Files/tex/GUI_Hp_Template.png"
 
 odpowiednik w programie mapa = new Map;mapa->Map_LoadStage( "Files/maps/stage1.stage", "Files/maps/stage1.png", 32 );
 
 
 TextureManager::LoadTexture( "GUI_Palete_Character_Info", "Files/tex/GUI_Palete_Character_Info.png" );
 TextureManager::LoadTexture( "GUI_Hp_Template", "Files/tex/GUI_Hp_Template.png" );
 TextureManager::LoadTexture( "GUI_ItemField", "Files/tex/GUI_ItemField.png" );
 
 TextureManager::LoadTexture( "GUI_Wizard_Basic", "Files/tex/GUI_Wizard_Basic.png" );
 TextureManager::LoadTexture( "GUI_Wizard_Explosion", "Files/tex/GUI_Wizard_Explosion.png" );
 TextureManager::LoadTexture( "GUI_Archer_Basic", "Files/tex/GUI_Archer_Basic.png" );
 TextureManager::LoadTexture( "GUI_Archer_MultiArrow", "Files/tex/GUI_Archer_MultiArrow.png" );
 
 TextureManager::LoadTexture( "BuffHp", "Files/tex/Buffs/BuffHp.png" );
 TextureManager::LoadTexture( "BuffHpRegen", "Files/tex/Buffs/BuffHpRegen.png" );
 TextureManager::LoadTexture( "BuffSp", "Files/tex/Buffs/BuffSp.png" );
 TextureManager::LoadTexture( "BuffSpRegen", "Files/tex/Buffs/BuffSpRegen.png" );
 
 TextureManager::LoadTexture( "MotionWizard", "Files/tex/Motions/MotionWizard.png" );
 
 TextureManager::LoadTexture( "MotionMobAlien", "Files/tex/Motions/MotionMobAlien.png" );
 
czasami sie tu program scrashuje na tym miejscu co widać w logach, a czasami nie. nie wiem czy to przez błąd w kodzi czy przez co wiec prosze o pomoc | 
|  | 
| DejaVu | » 2014-06-30 17:06:42 Crash może nastąpić wtedy, gdy tekstura jest w nieprawidłowym formacie, jednak problem wówczas jest powtarzalny (przynajmniej taką własność posiadał libjpeg/libpng jakiś czas temu z których korzysta SFML).
 Aplikacja również się wysypie, gdy tekstury będziesz chciał wczytać przed utworzeniem okna SFML.
 | 
|  | 
| Witold | » 2014-07-01 11:41:19 Ten kod jest sam w sobie trochę niebezpieczny. void TextureManager::EraseTexture( const string name ) Texture * TextureManager::GetT( const string tname ) Co się stanie jeśli takich tekstur niema? void TextureManager::LoadTexture( const string name, const string filename ) Wyciek pamięci jeśli nie załaduje tekstury. TextureManager::mapT & TextureManager::GetTexture() Modyfikujesz objekt z zewnątrz? | 
|  | 
| « 1 » |