IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Erreur difficile à localiser


Sujet :

C++

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut Erreur difficile à localiser
    Salut!

    Mon programme ne parvient à pas à afficher du texte (ou des images) à l'écran, et moi je ne parviens pas à savoir pourquoi ^^

    Je vous explique: il y a une classe MenuColonneCentree qui doit normalement appeler la fonction "draw()" d'une "Renderwindow" déclarée dans "main", et qui lui est passée par adresse.
    Je suis à-court d'idées, et je ne sais vraiment pas ce qui peut poser problème.

    Voici le message d'erreur que je rencontre:
    "terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

    This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."

    Et voici le code source:
    main.cpp:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    #include <SFML/Graphics.hpp>
    #include "MenuColonneCentree.h"
     
    using namespace sf;
     
    int main()
    {   RenderWindow window;
        window.create(VideoMode(1440, 900), "GVSC");
     
        MenuColonneCentree MenuColonneCentree_1(window);
        MenuColonneCentree_1.SetContenu({"SALUT!", "CA VA?"});
        MenuColonneCentree_1.ChoixAnimation(0);
     
     
        while (window.isOpen())
        {   Event event;
            while (window.pollEvent(event))
            {   if (event.type == Event::Closed)
                    window.close();
            }
     
            window.clear();
            MenuColonneCentree_1.Animation(1); // Ceci n'affiche rien (et c'est pas normal)
            window.display();
        }
     
        return 0;
    }
    MenuColonneCentree.h:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    #ifndef MENUCOLONNECENTREE_H_INCLUDED
    #define MENUCOLONNECENTREE_H_INCLUDED
     
    #include <SFML/Graphics.hpp>
    #include <string>
    #include <vector>
     
    #include "DecoupageQuadratiqueMiroir.h"
     
    using namespace sf;
    using namespace std;
     
     
     
    class MenuColonneCentree
    {   private:
            // Atttributs initialisés par le constructeur
            RenderWindow & window;
     
            // Autres attributs
            Font fonte;
            Color couleur;
            double width, height, hauteurTextePrincipal, hauteurTexteSecondaire, X, j;
            int options, animation, etape, longueurAnimation;
            vector<vector<Text> > texte;
            vector<vector<double> > posX, posY;
     
        public:
            int ligneSelectionnee; // Numéro de la ligne sélectionée (en partant de zéro)
            bool etatAnimation; // Temoin d'animation (true = animation en cours)
            bool etatExistence; // Temoin d'existence (true = objet actif)
     
            MenuColonneCentree(RenderWindow & argWINDOW);
     
            void SetContenu(vector<vector<string> > argCONTENU);
     
            void ChoixAnimation(int argNUMERO);
     
            void MouvementPreselection(int argMOUVEMENT);
     
            void Animation(int argSTEP);
    };
     
    #endif // MENUCOLONNECENTREE_H_INCLUDED
    MenuColonneCentree.cpp:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    #define SUIVI
     
    #include <SFML/Graphics.hpp>
     
    #include <windows.h>
    #include <string.h>
    #include <cstdlib>
     
    #ifdef SUIVI
    #include <iostream>
    #endif
     
    #include "MenuColonneCentree.h"
     
    using namespace std;
    using namespace sf;
     
     
     
    // Implémentation des méthodes de la classe
    MenuColonneCentree::MenuColonneCentree(RenderWindow & argWINDOW):
    window(argWINDOW) // Liste d'initialisation
    {   Font fonte; // Fonte pour le texte des menus
        fonte.loadFromFile("Fontes/FonteGVSC.ttf"); // Chargement d'un fichier font
     
        Color couleur; // Couleur pour le texte des menus
        couleur.r=255; couleur.g=100; couleur.b=0; couleur.a=255; // Création d'une couleur (rouge-orangé opaque)
     
        width=VideoMode::getDesktopMode().width; // Récupérer résolution horizontale de l'écran
        height=VideoMode::getDesktopMode().height; // Récupérer résolution verticale de l'écran
     
        hauteurTextePrincipal=height/13;
        hauteurTexteSecondaire=2*height/39;
     
        // Présélection par-défaut de l'animation zéro
        animation=4;
        etape=0;
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, MenuColonneCentree OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::SetContenu(vector<vector<string> > argCONTENU)
    {
        #ifdef SUIVI
        cout << "MenuColonneCentree, SetContenu lance" << endl;
        #endif
     
        options=(argCONTENU.size());
     
        // Redimensionner les vecteurs
        texte.resize(options);
        posX.resize(options);
        posY.resize(options);
     
        for (int index(0); index < options; index++)
        {   texte[index].resize(2);
            posX[index].resize(2);
            posY[index].resize(2);
        }
     
        ligneSelectionnee=0; // Présélection de la première ligne
     
        for (int index(0); index < options; index++)
        {   texte[index][0].setString(argCONTENU[index][0]);
            texte[index][1].setString(argCONTENU[index][1]);
     
            texte[index][0].setFont(fonte);
            texte[index][1].setFont(fonte);
     
            texte[index][0].setColor(couleur);
            texte[index][1].setColor(couleur);
     
            texte[index][0].setStyle(0);
            texte[index][1].setStyle(0);
     
            posX[index][0]=width/2;
            posX[index][1]=2*width/3;
     
            posY[index][0]=(7-options+2*index)*hauteurTextePrincipal;
            posY[index][1]=(8-options+2*index)*hauteurTextePrincipal;
        }
     
        etatExistence=true;
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, SetContenu OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::ChoixAnimation(int argNUMERO)
    {   animation=argNUMERO;
     
        switch (animation)
        {   case 0: // Animation standard
                etatAnimation=true;
                longueurAnimation=15;
            break;
            case 1: // Entrée en glissant pas la droite
                etatAnimation=false;
                longueurAnimation=15;
            break;
            case 2: // Sortie en glissant pas la gauche
                etatAnimation=false;
                longueurAnimation=15;
            break;
            case 3: // Sortie en glissant pas la droite
                etatAnimation=false;
                longueurAnimation=15;
            break;
            case 4: // Animation zéro (ne rien faire)
                etatAnimation=true;
            break;
        }
     
        for (int index(0); index < options; index++)
        {   texte[index][0].setCharacterSize(hauteurTextePrincipal);
            texte[index][0].setOrigin(texte[index][0].getGlobalBounds().width/2, hauteurTextePrincipal/2);
     
            texte[index][1].setCharacterSize(hauteurTexteSecondaire);
            texte[index][1].setOrigin(texte[index][1].getGlobalBounds().width/2, hauteurTextePrincipal/2);
     
            texte[index][0].setPosition(posX[index][0], posY[index][0]);
            texte[index][1].setPosition(posX[index][1], posY[index][1]);
        }
     
        etape=0; // Réinitialiser iTexte
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, ChoixAnimation OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::MouvementPreselection(int argMOUVEMENT)
    {   // argMOUVEMENT : mouvement à effectuer (+ = descendre ; 0 = rester ; - = monter)
     
        ligneSelectionnee+=argMOUVEMENT;
     
        if (ligneSelectionnee > options) {ligneSelectionnee=0;}
        else if (ligneSelectionnee < 0)  {ligneSelectionnee=options;}
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, MouvementPreselection OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::Animation(int argSTEP)
    {   // argSTEP : nombre d'étapes à passer dans l'animation
     
        etape+=argSTEP; // Incrémenter l'index d'animation
     
        switch (animation)
        {   case 0: // Animation standard de la ligne sélectionnée
                if (etape >= longueurAnimation-1) {etape-=longueurAnimation;} // Ne pas dépasser longueurAnimation-1
     
                j=1+DecoupageQuadratiqueMiroir(etape, longueurAnimation); // Prendre le facteur
     
                texte[ligneSelectionnee][0].setCharacterSize(j*hauteurTextePrincipal);
                texte[ligneSelectionnee][1].setCharacterSize(j*hauteurTexteSecondaire);
     
                texte[ligneSelectionnee][0].setOrigin(texte[ligneSelectionnee][0].getGlobalBounds().width/2, j*hauteurTextePrincipal/2);
                texte[ligneSelectionnee][1].setOrigin(texte[ligneSelectionnee][1].getGlobalBounds().width/2, j*hauteurTexteSecondaire/2);
     
                for (int index(0); index < options; index++)
                {   window.draw(texte[index][0]);
                    window.draw(texte[index][1]);
                }
            break;
            case 1: // Entrée en glissant par la droite
                if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
                {   etape=longueurAnimation-1;
     
                    etatAnimation=true;
                }
     
                X=width*DecoupageQuadratiqueMiroir(etape, longueurAnimation); // Prendre le facteur
     
                for (int index(0); index < options; index++)
                {   texte[index][0].setPosition(posX[index][0]+X, posY[index][0]);
                    texte[index][1].setPosition(posX[index][1]+X, posY[index][1]);
                    window.draw(texte[index][0]);
                    window.draw(texte[index][1]);
                }
            break;
            case 2: // Sortie en glissant par la gauche
                if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
                {   etape=longueurAnimation-1;
     
                    etatAnimation=true;
                    etatExistence=false;
                }
     
                X=width*DecoupageQuadratiqueMiroir(longueurAnimation-1-etape, longueurAnimation); // Prendre le facteur
     
                for (int index(0); index < options; index++)
                {   texte[index][0].setPosition(posX[index][0]+X, posY[index][0]);
                    texte[index][1].setPosition(posX[index][1]+X, posY[index][1]);
                    window.draw(texte[index][0]);
                    window.draw(texte[index][1]);
                }
            break;
            case 3: // Sortie en glissant par la droite
                if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
                {   etape=longueurAnimation-1;
     
                    etatAnimation=true;
                    etatExistence=false;
                }
     
                X=-width*DecoupageQuadratiqueMiroir(longueurAnimation-1-etape, longueurAnimation); // Prendre le facteur
     
                for (int index(0); index < options; index++)
                {   texte[index][0].setPosition(posX[index][0]+X, posY[index][0]);
                    texte[index][1].setPosition(posX[index][1]+X, posY[index][1]);
                    window.draw(texte[index][0]);
                    window.draw(texte[index][1]);
                }
            break;
            case 4: // Animation zéro (ne rien faire)
                for (int index(0); index < options; index++)
                {   window.draw(texte[index][0]);
                    window.draw(texte[index][1]);
                }
            break;
        }
    }

  2. #2
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    Bonjour

    En compilant en mode debug, des outils comme GDB ou Valgrind te diront la ligne qui pose problème.

    Peux-tu lancer ton programme avec gdb et une fois que celui plante, nous donner la sortie de gdb après avoir entré la commande bt (backtrack).

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    Là c'est le bordel...
    D'habitude, quand j'utilisais le débogueur, ça finissait par me donner des informations.
    Là, ça a juste fait ça:

    Nom : DGnrPXx8qgW_exemple.png
Affichages : 137
Taille : 179,4 Ko

    J'ai juste cliqué sur le "PLAY" encadré en rouge, en-haut.
    J'ai jamais vu ça (en tout cas je l'ai pas écrit), et j'ai aucune idée de ce que tout ça veut dire. Tu peux m'éclairer?

  4. #4
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    J'ai jamais utilisé gdb avec Code::Block.
    Si tu tapes up ou bt dans Command: et que tu cliques sur l’icône en face, il t'affiche de nouvelles choses ?

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    Je comprends même pas de quoi tu parles, là ^^

    On va commencer par le début: GDB fait-il partie de Codeblocks par-défaut, ou je dois commencer par me le procurer?

  6. #6
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    Code::Blocks est un IDE.
    Il peut utiliser GCC et GDB. Ces derniers sont biens installés sur ta machine (regarde le texte en bas de ton image : « Logs & others »).

    Pour mon message précédent, je parle encore de ton image, à la fin du cadre « Logs & others ».
    Apparemment, tu peux taper et exécuter des commandes.

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    Salut!

    Alors j'ai trouvé la barre "Command", et j'ai tapé "UP" dessus.
    Ca m'a rendu ceci:
    "> up
    #4 0x00470a3a in std::vector<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_range_initialize<char const*> (this=0x22feec, __first=0x47d0b3 "SALUT!", __last=0x47d0ac "CA VA?") at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:1168
    c:\program files\codeblocks\mingw\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_vector.h:1168:40349:beg:0x470a3a
    At c:\program files\codeblocks\mingw\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_vector.h:1168"

  8. #8
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    up va remonter un appel.
    bt va tous les afficher. Quel est le résultat de bt ?
    Si tu es bien en mode debug, tu peux faire aussi des print une_variable (et ça marche aussi avec la notation objet : print un_vector.size()).

  9. #9
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    Quand j'envoie "bt", ça fait pas de changement. J'imagine que "bt" est appelé automatiquement ^^
    Voilà le résultat:

    Building to ensure sources are up-to-date
    Selecting target:
    Debug
    Adding source dir: C:\Users\Moi\Document\(02) Document\(04) AutreDoc - jeux\Jeux vidéo\01 GVSC\TEST\
    Adding source dir: C:\Users\Moi\Document\(02) Document\(04) AutreDoc - jeux\Jeux vidéo\01 GVSC\TEST\
    Adding file: C:\Users\Moi\Document\(02) Document\(04) AutreDoc - jeux\Jeux vidéo\01 GVSC\TEST\bin\Debug\000.exe
    Changing directory to: C:/Users/Moi/DOCUM~1/(02)TR~1/(04)CA~1/JEUXVI~1/01GVSC~1/TEST/.
    Set variable: PATH=.;C:\Program Files\SFML-2.1\lib;C:\Program Files\CodeBlocks\MinGW\bin;C:\Program Files\CodeBlocks\MinGW;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared;C:\Program Files\Intel\DMIX;C:\Program Files\Intel\WiFi\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Pinnacle\Shared Files
    Starting debugger: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet -args C:/Users/Moi/DOCUM~1/(02)AUT~1/(04)CA~1/JEUXVI~1/01GVSC~1/TEST/bin/Debug/000.exe
    done
    Registered new type: wxString
    Registered new type: STL String
    Registered new type: STL Vector
    Setting breakpoints
    Debugger name and version: GNU gdb (GDB) 7.5
    Child process PID: 1784
    In __cxa_throw () ()
    #3 0x00453923 in std::_Vector_base<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_allocate (this=0x22feec, __n=4294967289) at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:169
    c:\program files\codeblocks\mingw\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_vector.h:169:5293:beg:0x453923
    At c:\program files\codeblocks\mingw\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_vector.h:169
    > bt
    #0 0x00409218 in __cxa_throw ()
    #1 0x00408305 in std::__throw_bad_alloc() ()
    #2 0x005ebc48 in ?? ()
    #3 0x00453923 in std::_Vector_base<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_allocate (this=0x22feec, __n=4294967289) at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:169
    #4 0x00470a3a in std::vector<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_range_initialize<char const*> (this=0x22feec, __first=0x47d0b3 "SALUT!", __last=0x47d0ac "CA VA?") at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:1168
    #5 0x00470af1 in std::vector<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_initialize_dispatch<char const*> (this=0x22feec, __first=0x47d0b3 "SALUT!", __last=0x47d0ac "CA VA?") at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:1148
    #6 0x00470b97 in std::vector<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::vector<char const*> (this=0x22feec, __first=0x47d0b3 "SALUT!", __last=0x47d0ac "CA VA?", __a=...) at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:393
    #7 0x00402173 in main () at C:\Users\Moi\Document\(02) Document\(04) AutreDocument - jeux\Jeux vidéo\01 GVSC\TEST\main.cpp:11
    > bt
    #0 0x00409218 in __cxa_throw ()
    #1 0x00408305 in std::__throw_bad_alloc() ()
    #2 0x005ebc48 in ?? ()
    #3 0x00453923 in std::_Vector_base<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_allocate (this=0x22feec, __n=4294967289) at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:169
    #4 0x00470a3a in std::vector<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_range_initialize<char const*> (this=0x22feec, __first=0x47d0b3 "SALUT!", __last=0x47d0ac "CA VA?") at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:1168
    #5 0x00470af1 in std::vector<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::_M_initialize_dispatch<char const*> (this=0x22feec, __first=0x47d0b3 "SALUT!", __last=0x47d0ac "CA VA?") at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:1148
    #6 0x00470b97 in std::vector<std::vector<std::string, std::allocator<std::string> >, std::allocator<std::vector<std::string, std::allocator<std::string> > > >::vector<char const*> (this=0x22feec, __first=0x47d0b3 "SALUT!", __last=0x47d0ac "CA VA?", __a=...) at c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_vector.h:393
    #7 0x00402173 in main () at C:\Users\Moi\Document\(02) Document\(04) AutreDocument - jeux\Jeux vidéo\01 GVSC\TEST\main.cpp:11

  10. #10
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    (bt affiche tous les appels, c'est inutile de le faire plusieurs fois.)

    Tu as la réponse à ta question :
    Citation Envoyé par Armulis Voir le message
    et je ne sais vraiment pas ce qui peut poser problème.
    C'est la ligne 11 de ton code :
    Citation Envoyé par Armulis Voir le message
    #7 0x00402173 in main () at C:\Users\Michael\TreizeDeFeu\(02) TreizeDeFeu\(04) CarréBrûlant - jeux\Jeux vidéo\01 Ghost VS Clown\TEST\main.cpp:11
    Tu essayes de convertir un {"SALUT!", "CA VA?"} en vector<vector<string>>.
    Tu n'avais pas de warning à la compilation ? Tu as bien activé -Wall, -Wextra, -std=c++11 et -pedantic dans la configuration du compilateur ?

  11. #11
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    Non, j'ai pas activé tous les avertissements. Je change ça tout de suite et je change l'appel. J'écris {{"SALUT!", "CA VA?"}}

    Maintenant, ça donne ça:
    Building to ensure sources are up-to-date
    Selecting target:
    Debug
    Adding source dir: C:\Users\Moi\Document\(02) Document\(04) AutreDoc - jeux\Jeux vidéo\01 GVSC\TEST\
    Adding source dir: C:\Users\Moi\Document\(02) Document\(04) AutreDoc - jeux\Jeux vidéo\01 GVSC\TEST\
    Adding file: C:\Users\Moi\Document\(02) Document\(04) AutreDoc - jeux\Jeux vidéo\01 GVSC\TEST\bin\Debug\000.exe
    Changing directory to: C:/Users/Moi/DOCUM~1/(02)TR~1/(04)CA~1/JEUXVI~1/01GVSC~1/TEST/.
    Set variable: PATH=.;C:\Program Files\SFML-2.1\lib;C:\Program Files\CodeBlocks\MinGW\bin;C:\Program Files\CodeBlocks\MinGW;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared;C:\Program Files\Intel\DMIX;C:\Program Files\Intel\WiFi\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Pinnacle\Shared Files
    Starting debugger: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet -args C:/Users/Moi/TREIZE~1/(02)TR~1/(04)CA~1/JEUXVI~1/01GVSC~1/TEST/bin/Debug/000.exe
    done
    Registered new type: wxString
    Registered new type: STL String
    Registered new type: STL Vector
    Setting breakpoints
    Debugger name and version: GNU gdb (GDB) 7.5
    Child process PID: 5656

  12. #12
    r0d
    r0d est déconnecté
    Expert éminent

    Homme Profil pro
    tech lead c++ linux
    Inscrit en
    Août 2004
    Messages
    4 262
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : tech lead c++ linux

    Informations forums :
    Inscription : Août 2004
    Messages : 4 262
    Points : 6 680
    Points
    6 680
    Billets dans le blog
    2
    Par défaut
    Bonjour,

    difficile de se prononcer précisément, mais je vois une grosse erreur:

    MenuColonneCentree.h:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    // ...
     
    class MenuColonneCentree
    {   
    // ...
            void SetContenu(vector<vector<string> > argCONTENU);
    // ...
    };
    or, dans main.cpp, on a:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    //...
        MenuColonneCentree_1.SetContenu({"SALUT!", "CA VA?"});
        // ...
    Le problème c'est que {"SALUT!", "CA VA?"} est un vector<string>, mais la fonction prend un vector<vector<string>>. Je ne comprend d'ailleurs pas pourquoi ça compile.
    « L'effort par lequel toute chose tend à persévérer dans son être n'est rien de plus que l'essence actuelle de cette chose. »
    Spinoza — Éthique III, Proposition VII

  13. #13
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    Oui, c'est vrai. Je sais pas non-plus pourquoi le compilateur traverse ça. Peut-être qu'il interprète ça, mais je sais pas trop ce que ça donne. J'ai corrigé, en tout cas, mais ça change rien. J'ai déjà donné le résultat du debugger, juste au-dessus =D

  14. #14
    r0d
    r0d est déconnecté
    Expert éminent

    Homme Profil pro
    tech lead c++ linux
    Inscrit en
    Août 2004
    Messages
    4 262
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : tech lead c++ linux

    Informations forums :
    Inscription : Août 2004
    Messages : 4 262
    Points : 6 680
    Points
    6 680
    Billets dans le blog
    2
    Par défaut
    Qu'as-tu corrigé exactement?
    A quelle ligne ça plante?
    « L'effort par lequel toute chose tend à persévérer dans son être n'est rien de plus que l'essence actuelle de cette chose. »
    Spinoza — Éthique III, Proposition VII

  15. #15
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    J'ai corrigé la "grosse erreur" que tu avais signalée, au niveau de l'appel de "MenuColonneCentree.SetContenu". J'ai remplacé {"SALUT!", "CA VA?"} par {{"SALUT!", "CA VA?"}}, pour que ça corresponde à l'implémentation de cette fonction (vector<vector<string> >).

    En fait, le programme ne se plante pas (plus), mais il n'affiche rien =D

    Je me demande si le passage par référence de la Renderwindow ne poserait pas problème, parce qu'on m'a conseillé de le faire et j'ai simplement fait ce qu'on me disait, mais j'ai l'impression que ça ne marche pas. En fait, il y avait plein de restrictions. Par-exemple, j'étais obligé d'attribuer à la RenderWindow de la classe directement avec la liste d'initialisation du constructeur. Autrement, ça marchait pas. Est-ce que quelqu'un peut m'expliquer comment me renseigner là-dessus?

    Voici un extrait du constructeur de ma classe:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    MenuColonneCentree::MenuColonneCentree(RenderWindow & argWINDOW):
    window(argWINDOW) // Liste d'initialisation
    {}
    EDIT:
    Non, c'est pas le problème apparemment. J'ai essayé de mettre ceci...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
        Font fonte1;
        fonte1.loadFromFile("Fontes/FonteGVSC.ttf");
     
        Text texte1;
        texte1.setString("LALALA!");
        texte1.setFont(fonte1);
        texte1.setColor(Color::White);
        texte1.setCharacterSize(50);
        texte1.setPosition(0, 0);
     
        window.draw(texte1);
    ...dans "MenuColonneCentree.Animation()", et ça s'affiche très bien. Il faut que je réécrive cette classe en partant de ça, et je verrai ce que ça donne. Je guette vos réponses et vos suggestions, mais pour l'instant je note que le sujet est "résolu". =D
    Premières observations: c'est un problème de durée de vie, je crois. J'y travaille =D

  16. #16
    Nouveau membre du Club
    Homme Profil pro
    Etudiant en génie mécanique
    Inscrit en
    Mars 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Etudiant en génie mécanique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Points : 33
    Points
    33
    Par défaut
    Oh mon dieu, saloperie que c'était nul!
    En plus je suis tombé dessus par hasard, quelle horreur! xD

    Regardez-moi ce constructeur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    MenuColonneCentree::MenuColonneCentree(RenderWindow & argWINDOW):
    window(argWINDOW) // Liste d'initialisation
    {   Font fonte; // Fonte pour le texte des menus
        fonte.loadFromFile("Fontes/FonteGVSC.ttf"); // Chargement d'un fichier font
     
        Color couleur; // Couleur pour le texte des menus
        couleur.r=255; couleur.g=100; couleur.b=0; couleur.a=255; // Création d'une couleur (rouge-orangé opaque)
     
        width=VideoMode::getDesktopMode().width; // Récupérer résolution horizontale de l'écran
        height=VideoMode::getDesktopMode().height; // Récupérer résolution verticale de l'écran
     
        hauteurTextePrincipal=height/13;
        hauteurTexteSecondaire=2*height/39;
     
        // Présélection par-défaut de l'animation zéro
        animation=4;
        etape=0;
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, MenuColonneCentree OK" << endl;
        #endif
    }
    Ca ne vous choque pas?
    Lignes 3 et 6: je redéclare la fonte et la couleur. Tu m'étonnes que le programme avait l'air de bien fonctionner et que pourtant on ne voyait rien: j'affichais des objets invisibles! =D

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Flex4] erreur non localisée
    Par execrable dans le forum Flex
    Réponses: 1
    Dernier message: 27/04/2011, 11h46
  2. Une erreur difficile à détecter
    Par herzak dans le forum Langage
    Réponses: 8
    Dernier message: 30/12/2010, 21h07
  3. FOP + erreurs non localisées
    Par yozine dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 07/09/2009, 11h05
  4. Erreur non localisée
    Par nezdeboeuf62 dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 24/01/2008, 22h13
  5. Message d'erreur difficilement interpretable
    Par cococococococo dans le forum MATLAB
    Réponses: 2
    Dernier message: 29/06/2007, 10h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo