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 :

Application qui frezze avec Qt (problème avec les exceptions)


Sujet :

C++

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 106
    Par défaut Application qui frezze avec Qt (problème avec les exceptions)
    Bonjour,

    J'ai un problème avec les exceptions dans Qt. Dès que je fais un throw, le code du catch n'est pas exécuté, et l'application freeze. Voici un code simple montrant ce que je fais :

    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
    #include <QtGui/QApplication>
    #include <QPushButton>
    #include <iostream>
    #include "mainwindow.h"
     
    using namespace std;
     
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        QPushButton bouton("truc");
        MainWindow w;
     
        cout << "Avant exeception" <<endl;
        try
        {
     
            throw std::exception(); //1
        }
        catch(...)
        {
            bouton.setText("Exception levée");
            bouton.show();
        }
        cout << "Apres exepction"<<endl;
     
        w.show();
        return a.exec();
    }

    J'utilise Qt Creator, et ce même code marche sur le PC d'un copain (on a tous les 2 vista, la même version de QtCreator, etc).

    Avez-vous une idée d'où peut venir l'erreur ?

    Merci

  2. #2
    Alp
    Alp est déconnecté
    Expert confirmé

    Avatar de Alp
    Homme Profil pro
    Inscrit en
    Juin 2005
    Messages
    8 575
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Juin 2005
    Messages : 8 575
    Par défaut
    En enlevant tout ce qui concerne MainWindow, je n'ai aucun soucis. Et de toute manière, w n'est pas concernée.

    Pourrais-tu nous copier/coller le Makefile généré dans une balise CODE ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 106
    Par défaut
    Le voici :
    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
    #-------------------------------------------------
    #
    # Project created by QtCreator 2009-05-09T20:10:19
    #
    #-------------------------------------------------
     
    TARGET = dd
    TEMPLATE = app
     
     
    SOURCES += main.cpp\
            mainwindow.cpp
     
    HEADERS  += mainwindow.h
     
    FORMS    += mainwindow.ui

  4. #4
    Alp
    Alp est déconnecté
    Expert confirmé

    Avatar de Alp
    Homme Profil pro
    Inscrit en
    Juin 2005
    Messages
    8 575
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Juin 2005
    Messages : 8 575
    Par défaut
    C'est pas le .pro ça ?

    En gros, je voudrais voir tes options de compilations, c-à-d ce qui est donné à ton compilateur, car c'est la seule éventuelle différence entre mon poste et celui de ton ami d'un côté, le tien de l'autre. Le code est le même.

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 106
    Par défaut
    Ah oui désolé
    Voila le makfile :
    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
    #############################################################################
    # Makefile for building: dd
    # Generated by qmake (2.01a) (Qt 4.5.1) on: sam. 30. mai 12:45:12 2009
    # Project:  dd.pro
    # Template: app
    #############################################################################
     
    ####### Compiler, tools and options
     
    CC            = gcc
    CXX           = g++
    DEFINES       = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
    CFLAGS        = -g -Wall $(DEFINES)
    CXXFLAGS      = -g -frtti -fexceptions -mthreads -Wall $(DEFINES)
    INCPATH       = -I"c:\Qt\2009.02\qt\include\QtCore" -I"c:\Qt\2009.02\qt\include\QtGui" -I"c:\Qt\2009.02\qt\include" -I"c:\Qt\2009.02\qt\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\2009.02\qt\mkspecs\win32-g++"
    LINK        =        g++
    LFLAGS        =        -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows
    LIBS        =        -L"c:\Qt\2009.02\qt\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
    QMAKE         = c:\Qt\2009.02\qt\bin\qmake.exe
    IDC           = c:\Qt\2009.02\qt\bin\idc.exe
    IDL           = midl
    ZIP           = zip -r -9
    DEF_FILE      = 
    RES_FILE      = 
    COPY          = copy /y
    COPY_FILE     = $(COPY)
    COPY_DIR      = xcopy /s /q /y /i
    DEL_FILE      = del
    DEL_DIR       = rmdir
    MOVE          = move
    CHK_DIR_EXISTS= if not exist
    MKDIR         = mkdir
    INSTALL_FILE    = $(COPY_FILE)
    INSTALL_PROGRAM = $(COPY_FILE)
    INSTALL_DIR     = $(COPY_DIR)
     
    ####### Output directory
     
    OBJECTS_DIR   = debug
     
    ####### Files
     
    SOURCES       = main.cpp \
    		mainwindow.cpp debug\moc_mainwindow.cpp
    OBJECTS       = debug/main.o \
    		debug/mainwindow.o \
    		debug/moc_mainwindow.o
    DIST          = 
    QMAKE_TARGET  = dd
    DESTDIR        = debug\ #avoid trailing-slash linebreak
    TARGET         = dd.exe
    DESTDIR_TARGET = debug\dd.exe
     
    ####### Implicit rules
     
    .SUFFIXES: .cpp .cc .cxx .c
     
    .cpp.o:
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
     
    .cc.o:
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
     
    .cxx.o:
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
     
    .c.o:
    	$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
     
    ####### Build rules
     
    first: all
    all: Makefile.Debug  $(DESTDIR_TARGET)
     
    $(DESTDIR_TARGET): ui_mainwindow.h $(OBJECTS) 
    	$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS)  $(LIBS)
     
     
    qmake:  FORCE
    	@$(QMAKE) -spec c:\Qt\2009.02\qt\mkspecs\win32-g++ -win32 -o Makefile.Debug dd.pro
     
    dist:
    	$(ZIP) dd.zip $(SOURCES) $(DIST) dd.pro c:\Qt\2009.02\qt\mkspecs\qconfig.pri c:\Qt\2009.02\qt\mkspecs\features\qt_functions.prf c:\Qt\2009.02\qt\mkspecs\features\qt_config.prf c:\Qt\2009.02\qt\mkspecs\features\exclusive_builds.prf c:\Qt\2009.02\qt\mkspecs\features\default_pre.prf c:\Qt\2009.02\qt\mkspecs\features\win32\default_pre.prf c:\Qt\2009.02\qt\mkspecs\features\debug.prf c:\Qt\2009.02\qt\mkspecs\features\debug_and_release.prf c:\Qt\2009.02\qt\mkspecs\features\default_post.prf c:\Qt\2009.02\qt\mkspecs\features\win32\default_post.prf c:\Qt\2009.02\qt\mkspecs\features\build_pass.prf c:\Qt\2009.02\qt\mkspecs\features\win32\rtti.prf c:\Qt\2009.02\qt\mkspecs\features\win32\exceptions.prf c:\Qt\2009.02\qt\mkspecs\features\win32\stl.prf c:\Qt\2009.02\qt\mkspecs\features\shared.prf c:\Qt\2009.02\qt\mkspecs\features\warn_on.prf c:\Qt\2009.02\qt\mkspecs\features\qt.prf c:\Qt\2009.02\qt\mkspecs\features\win32\thread.prf c:\Qt\2009.02\qt\mkspecs\features\moc.prf c:\Qt\2009.02\qt\mkspecs\features\win32\windows.prf c:\Qt\2009.02\qt\mkspecs\features\resources.prf c:\Qt\2009.02\qt\mkspecs\features\uic.prf c:\Qt\2009.02\qt\mkspecs\features\yacc.prf c:\Qt\2009.02\qt\mkspecs\features\lex.prf c:\Qt\2009.02\qt\mkspecs\features\include_source_dir.prf c:\Qt\2009.02\qt\lib\qtmaind.prl  HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES 
     
    clean: compiler_clean 
    	-$(DEL_FILE) debug\main.o debug\mainwindow.o debug\moc_mainwindow.o
     
    distclean: clean
    	-$(DEL_FILE) $(DESTDIR_TARGET)
    	-$(DEL_FILE) Makefile.Debug
     
    mocclean: compiler_moc_header_clean compiler_moc_source_clean
     
    mocables: compiler_moc_header_make_all compiler_moc_source_make_all
     
    compiler_moc_header_make_all: debug/moc_mainwindow.cpp
    compiler_moc_header_clean:
    	-$(DEL_FILE) debug\moc_mainwindow.cpp
    debug/moc_mainwindow.cpp: mainwindow.h
    	C:/Qt/2009.02/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 mainwindow.h -o debug\moc_mainwindow.cpp
     
    compiler_rcc_make_all:
    compiler_rcc_clean:
    compiler_image_collection_make_all: qmake_image_collection.cpp
    compiler_image_collection_clean:
    	-$(DEL_FILE) qmake_image_collection.cpp
    compiler_moc_source_make_all:
    compiler_moc_source_clean:
    compiler_uic_make_all: ui_mainwindow.h
    compiler_uic_clean:
    	-$(DEL_FILE) ui_mainwindow.h
    ui_mainwindow.h: mainwindow.ui
    	c:\Qt\2009.02\qt\bin\uic.exe mainwindow.ui -o ui_mainwindow.h
     
    compiler_yacc_decl_make_all:
    compiler_yacc_decl_clean:
    compiler_yacc_impl_make_all:
    compiler_yacc_impl_clean:
    compiler_lex_make_all:
    compiler_lex_clean:
    compiler_clean: compiler_moc_header_clean compiler_uic_clean 
     
     
     
    ####### Compile
     
    debug/main.o: main.cpp mainwindow.h
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\main.o main.cpp
     
    debug/mainwindow.o: mainwindow.cpp mainwindow.h \
    		ui_mainwindow.h
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\mainwindow.o mainwindow.cpp
     
    debug/moc_mainwindow.o: debug/moc_mainwindow.cpp 
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_mainwindow.o debug\moc_mainwindow.cpp
     
    ####### Install
     
    install:   FORCE
     
    uninstall:   FORCE
     
    FORCE:

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 106
    Par défaut
    Pour info pour ceux qui ont le même problème : en prenant une version de mingw plus récente ça marche correctement

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

Discussions similaires

  1. Problème avec la fonction pow(les puissance)
    Par Clément76 dans le forum C
    Réponses: 10
    Dernier message: 04/10/2006, 12h44
  2. Réponses: 2
    Dernier message: 02/08/2006, 16h46
  3. [Tableaux] Problème avec un array et les pseudo frame
    Par azerty53 dans le forum Langage
    Réponses: 6
    Dernier message: 10/05/2006, 14h57
  4. Problème avec l'unicode et les exceptions
    Par Rafy dans le forum C++
    Réponses: 5
    Dernier message: 07/02/2006, 00h52
  5. problème avec strtok pour récupérer les vides
    Par manikou dans le forum MFC
    Réponses: 4
    Dernier message: 02/06/2005, 20h08

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