bonsoir,
je suis actuellement sur un code Qt/OpenGL qui produit des animations en physique.
J'essaie d'inclure la rotation dans un GLWidget avec les méthodes mousePressEvent et mouseMoveEvent.
Pour cela, au lieu de déclarer une variable globale QPoint lastPos dans GLWidget.cpp qui donne les coordonnées de la souris, j'essaie de mettre cette variable comme donnée membre dans la classe GLWidget dérivée de QGLWidget.
et là, problème à l'exécution, j'obtiens une erreur du type "corrupted double-linked list" :
*** glibc detected *** ./YourGalaxy: corrupted double-linked list: 0x0000000001682a00 ***
======= Backtrace: =========
/lib/libc.so.6(+0x71bd6)[0x7f665940ebd6]
...
Voici le header GLWidget.hpp :
et ici le constructeur dans GLWidget.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 #ifndef GLWIDGET_H #define GLWIDGET_H #include <QGLShaderProgram> #include <QGLWidget> #include <QPoint> #include <QTimer> #include "NBody.hpp" #include "Timer.h" class GLWidget : public QGLWidget { Q_OBJECT public: GLWidget(QWidget *parent = NULL); ~GLWidget(); NBody *Galaxy; float m_particleRadius; float m_pointScale; QPoint lastPos; GLubyte *textureImage; GLuint texture; Timer timer; GLuint m_program; QTimer *m_timer; int count; double n_fps; GLuint _compileProgram(const char *source); void LoadGLTextures(); void createVBO(uint size); void draw(); void printStats(); void zoom_scale(double factor); protected : void initializeGL(); void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); private slots: void processCurrent(); private: int w_width; int w_height; GLfloat g_nearPlane; GLfloat g_farPlane; char** stats; }; #endif
Lors de l'allocation d'un objet "GLWidget", comme la variable lasPos est déclarée statique, je ne comprends pas pourquoi j'ai ce type d'erreur.
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 GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent) { char *my_argv[] = { "NBody", NULL }; int my_argc = 1; int status; m_particleRadius = 0.5f; m_pointScale = 100.0f; w_width = 600; w_height = 600; g_nearPlane = 0.1f; g_farPlane = 1000.0f; count = 0; n_fps = 0.0; stats = new char* [3] ; for( int i = 0 ; i < 3 ; i++ ) stats[i] = new char[10]; Galaxy = new NBody("OpenCL NBody"); if (Galaxy->initialize() != SDK_SUCCESS) cout << "NBody initialize error" << endl; if (Galaxy->parseCommandLine(my_argc, my_argv) != SDK_SUCCESS) cout << "NBody parseCommand error" << endl; status = Galaxy->setup(); if (status != SDK_SUCCESS) cout << "NBody setup error" << endl; status = Galaxy->run(); if(status != SDK_SUCCESS) cout << "Sample Run Program Failed" << endl; setFormat(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer)); timer.start(); m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(processCurrent())); m_timer->start(0); }
J'ai aussi essayé de mettre lastPos en donnée membre privée mais toujours la même erreur. Est-ce parce que je n'ai pas initialisé cette variable dans le constructeur ?
la backtrace donne :
Quelqu'un pourrait m'expliquer ce qui ne va pas ?
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 (gdb) bt #0 0x00007ffff53501b5 in raise () from /lib/libc.so.6 #1 0x00007ffff5352fc0 in abort () from /lib/libc.so.6 #2 0x00007ffff538637b in ?? () from /lib/libc.so.6 #3 0x00007ffff538fbd6 in ?? () from /lib/libc.so.6 #4 0x00007ffff539004d in ?? () from /lib/libc.so.6 #5 0x00007ffff5392354 in ?? () from /lib/libc.so.6 #6 0x00007ffff5394a30 in malloc () from /lib/libc.so.6 #7 0x00007fffee75edec in ?? () from /usr/lib/dri/fglrx_dri.so #8 0x00007fffee876c2f in ?? () from /usr/lib/dri/fglrx_dri.so #9 0x00007fffee8e4e2b in ?? () from /usr/lib/dri/fglrx_dri.so #10 0x00007fffee8e5436 in ?? () from /usr/lib/dri/fglrx_dri.so #11 0x00007fffee879ff2 in ?? () from /usr/lib/dri/fglrx_dri.so #12 0x00007fffee87cf94 in ?? () from /usr/lib/dri/fglrx_dri.so #13 0x00007fffee87d0d6 in ?? () from /usr/lib/dri/fglrx_dri.so #14 0x00007fffee614610 in ?? () from /usr/lib/dri/fglrx_dri.so #15 0x00007fffee620783 in ?? () from /usr/lib/dri/fglrx_dri.so #16 0x00007fffee621477 in ?? () from /usr/lib/dri/fglrx_dri.so #17 0x00007fffee621825 in ?? () from /usr/lib/dri/fglrx_dri.so #18 0x00007fffed98d07e in ?? () from /usr/lib/dri/fglrx_dri.so #19 0x0000000000409164 in GLWidget::draw() () #20 0x0000000000409d15 in GLWidget::processCurrent() () #21 0x00000000004209b0 in GLWidget::qt_metacall(QMetaObject::Call, int, void**) () #22 0x00007ffff6d9e1f7 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/libQtCore.so.4 #23 0x00007ffff6d97889 in QObject::event(QEvent*) () from /usr/lib/libQtCore.so.4 #24 0x00007ffff72bf4ac in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4 #25 0x00007ffff72c5e4d in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4 #26 0x00007ffff6d864fc in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4 #27 0x00007ffff6db588e in ?? () from /usr/lib/libQtCore.so.4 #28 0x00007ffff6db28f4 in ?? () from /usr/lib/libQtCore.so.4 #29 0x00007ffff47bd6f2 in g_main_context_dispatch () from /lib/libglib-2.0.so.0 #30 0x00007ffff47c1568 in ?? () from /lib/libglib-2.0.so.0 #31 0x00007ffff47c171c in g_main_context_iteration () from /lib/libglib-2.0.so.0 #32 0x00007ffff6db25e3 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4 #33 0x00007ffff73721fe in ?? () from /usr/lib/libQtGui.so.4 #34 0x00007ffff6d85222 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4 #35 0x00007ffff6d8560c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4 #36 0x00007ffff6d896db in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4 #37 0x000000000040b311 in main ()
Partager