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

wxWidgets Discussion :

Erreur de segmentation (core dumped)


Sujet :

wxWidgets

  1. #1
    Membre du Club
    Inscrit en
    Novembre 2006
    Messages
    91
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 91
    Points : 47
    Points
    47
    Par défaut Erreur de segmentation (core dumped)
    Bonsoir,
    voila je développe une petite application en C++ .A lexecution j'ai cette affichage..
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    mourad@Mourad:~/ihm-test$ ./drawtri
    Erreur de segmentation (core dumped)
    voici mon programme:
    mainframe.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
    #include <stdio.h>
    
    #include <stdlib.h>
    
    #include <fstream>
    
    
    #include "mainframe.h"
    
    #include "dialogs.h"
    
    
    
    
    
    
    BEGIN_EVENT_TABLE(CMainFrame, wxFrame)
    	
    	EVT_MENU(MENU_NEW, CMainFrame::OnNew)
    
    	EVT_MENU(MENU_OPEN, CMainFrame::OnOpen)
    
    	EVT_MENU(MENU_QUIT, CMainFrame::OnQuit)
    
    	EVT_MENU(MENU_TOOLBAR, CMainFrame::OnToolbar)
    
    	EVT_MENU(MENU_THICKNESS, CMainFrame::OnThickness) 
    
    	EVT_MENU(MENU_COLOR, CMainFrame::OnColor) 
    
    	EVT_MENU(MENU_MANAGE, CMainFrame::OnManage) 
    
    	EVT_MENU(MENU_RELEASE, CMainFrame::OnRelease) 
    
    	EVT_MENU(MENU_HELP,CMainFrame::OnHelp)
    
    END_EVENT_TABLE()
    
    
    
    //Le constructeur
    
    CMainFrame::CMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
    
    : wxFrame((wxFrame *)NULL, -1, title, pos, size) 
    
    {
    
    	
    
    } 
    
    
    
    
    
    //Création de la toolbar
    
    void CMainFrame::CreateMyToolbar(){
    
    	wxToolBar *m_toolbar=CreateToolBar(wxNO_BORDER|wxTB_HORIZONTAL,TOOLBAR_TOOLS);
    
    	wxBitmap toolBarBitmaps[4] ;
    
    	toolBarBitmaps[0] = wxBitmap("new.bmp",wxBITMAP_TYPE_BMP) ;
    
    	toolBarBitmaps[1] = wxBitmap("open.bmp",wxBITMAP_TYPE_BMP) ;
    
    	toolBarBitmaps[2] = wxBitmap("save.bmp",wxBITMAP_TYPE_BMP) ;
    
    	toolBarBitmaps[3] = wxBitmap("draw.bmp",wxBITMAP_TYPE_BMP) ;
    
    	m_toolbar->SetToolBitmapSize(wxSize(toolBarBitmaps[0].GetWidth(),toolBarBitmaps[0].GetHeight()));
    
    	m_toolbar->AddTool(MENU_NEW,"Nouveau",toolBarBitmaps[0],"Créer un nouveau fichier");
    
    	m_toolbar->AddTool(MENU_OPEN,"Ouvrir",toolBarBitmaps[1],"Ouvrir un fichier");
    
    	m_toolbar->AddTool(MENU_SAVE,"Sauvegarder",toolBarBitmaps[2],"Sauvegarder le fichier");
    
    	m_toolbar->AddSeparator();
    
    	m_toolbar->AddCheckTool(MENU_DRAW,"Dessiner",toolBarBitmaps[3]);
    	SetToolBar(m_toolbar) ;
    	m_toolbar->Realize();
    
    	
    	
    
    
    
    }
    
    
    
    //Implémentation des fonctions liées aux événements
    
    
    void CMainFrame::OnNew(wxCommandEvent& event) {
    
    	
    
    }
    
    void CMainFrame::OnOpen(wxCommandEvent& event){
    
    	}
    
    void CMainFrame::OnQuit(wxCommandEvent& event)  {
    
    	Close(TRUE);
    
    }
    
    
    void CMainFrame::CMainFrame::OnToolbar(wxCommandEvent& event)  {
    	if(m_toolbar->IsShown())
    
    		m_toolbar->Show(false);
    		
    
    	else
    
    		m_toolbar->Show(true);
    		
    
    	
    
    	
    
    	
    
    }
    
    void CMainFrame::OnThickness(wxCommandEvent& event){
    
    	ThicknessDialog tdlg(this, -1, "Epaisseur trait");
    
    	tdlg.ShowModal();
    	
    
    }
    
    void  CMainFrame::OnColor(wxCommandEvent& event){
    	
    	ColourDialog cdlg(this, -1, "Couleur");
    
    	cdlg.ShowModal();
    	
    }
    
    void  CMainFrame::OnManage(wxCommandEvent& event){
    
    	
    
    	ManageDialog mdlg(this, -1, "Gestion des triangles");
    
    	mdlg.ShowModal();
    	
    }
    
    
    
    
    
    void CMainFrame::OnRelease(wxCommandEvent& event) {
    
    	VersionDialog vdlg(this, -1, "Version");
    
    	vdlg.ShowModal();
    
    }
    
    
    void CMainFrame::OnHelp(wxCommandEvent& event){
    	help.DisplayContents();	
    
    }
    mainframe.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
    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
     
    #ifndef __MAINFRAME_H__
     
    #define __MAINFRAME_H__
    #include <string.h>
     
    #include <wx/html/helpctrl.h>
     
    #include <wx/wx.h>
     
     
     
     
     
    class CMainFrame: public wxFrame {
     
    public:
     
     
     
    	CMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
    	int epaisseurtraitcourante;
    	wxColour couleurcourante;
     
    	bool is_drawing;// indique si le bouton sur la toolBar est enfoncée ou non
     
     
     
     
    	wxHtmlHelpController help;
    	void CreateMyToolbar();
     
    	//les fonctions auxiliaires
     
     
     
     
    private:
     
    	wxToolBar *m_toolbar;
    	wxMenuBar *menu_bar ;
     
    	DECLARE_EVENT_TABLE();
     
     
     
    	// les fonctions liées aux événements
     
    	void OnNew(wxCommandEvent& event); 
     
    	void OnOpen(wxCommandEvent& event) ;
     
    	void OnSave(wxCommandEvent& event) ;
     
    	void OnQuit(wxCommandEvent& event) ;
     
    	void OnToolbar(wxCommandEvent& event) ;
     
    	void OnThickness(wxCommandEvent& event) ;
     
    	void OnColor(wxCommandEvent& event) ;
     
    	void OnManage(wxCommandEvent& event) ;
     
    	void OnRelease(wxCommandEvent& event) ;
     
    	void OnDraw(wxCommandEvent& event) ;
     
    	void OnHelp(wxCommandEvent& event);
     
     
     
    }; //MyFrame
     
     
     
     
     
     
     
     
     
     
     
    // l'énumération des ID
     
    enum{
     
    	MENU_NEW=0,
     
    	MENU_OPEN=1,
     
    	MENU_SAVE=2,
     
    	MENU_QUIT=3,
     
    	MENU_THICKNESS=4,
     
    	MENU_COLOR=5,
     
    	MENU_MANAGE=6,
     
    	MENU_RELEASE=7,
     
    	MENU_TOOLBAR=8,
     
    	TOOLBAR_TOOLS=9,
     
    	MENU_HELP=10,
     
    	MENU_DRAW=11
     
     };
     
     
     
    #endif
    Quand je fait un dbuggage, j'ai une erreur sur cette methode

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
     
    void CMainFrame::CMainFrame::OnToolbar(wxCommandEvent& event)  {
    	if(m_toolbar->IsShown())
     
    		m_toolbar->Show(false);
     
     
    	else
     
    		m_toolbar->Show(true);
    Cette methode me permet d'afficher ou de cacher une barre d'outil.
    merci d'avance

  2. #2
    Rédacteur

    Avatar de Davidbrcz
    Homme Profil pro
    Ing Supaéro - Doctorant ONERA
    Inscrit en
    Juin 2006
    Messages
    2 307
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : Suisse

    Informations professionnelles :
    Activité : Ing Supaéro - Doctorant ONERA

    Informations forums :
    Inscription : Juin 2006
    Messages : 2 307
    Points : 4 732
    Points
    4 732
    Par défaut
    Est ce que CreateMyToolbar est appelé (pas lu le code en détail mais me semblerai que non) ?

    Car sinon m_toolbar vaut toujours NULL quand tu rentre dans CMainFrame::OnToolbar et donc quand tu déférence => boom
    "Never use brute force in fighting an exponential." (Andrei Alexandrescu)

    Mes articles dont Conseils divers sur le C++
    Une très bonne doc sur le C++ (en) Why linux is better (fr)

  3. #3
    Membre du Club
    Inscrit en
    Novembre 2006
    Messages
    91
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 91
    Points : 47
    Points
    47
    Par défaut Erreur de segmentation (core dumped) OK
    C bon j'ai trouvé l'erreur: j'ai déclaré :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    wxToolBar  *m_toolbar
    deux fois, dans le fichier mainframe.h et maiframe.ccp.
    merci

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    20
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 20
    Points : 21
    Points
    21
    Par défaut
    Pour info mourad, et comme indiqué au dessus, la plupart du temps une segmentation fault est égale à l'utilisation d'un pointeur null ou mal initialisé (ou encore un delete sur un pointeur déjà deleté, etc...).

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

Discussions similaires

  1. Erreur de segmentation (core dumped)
    Par yansei dans le forum C
    Réponses: 13
    Dernier message: 07/06/2008, 11h51
  2. Erreur de segmentation (core dumped)
    Par benja507 dans le forum Débuter
    Réponses: 11
    Dernier message: 14/05/2008, 17h37
  3. Réponses: 6
    Dernier message: 14/01/2008, 16h47
  4. erreur de segmentation core dumped
    Par panganino dans le forum Langage
    Réponses: 2
    Dernier message: 03/01/2008, 12h45
  5. Réponses: 5
    Dernier message: 04/11/2007, 13h39

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