Salut tout le monde,
Lorsque j'appelle une méthode (je poste le code correspondant par la suite), visual studio m'envoie une exception (Violation d'accès lors de l'écriture à l'emplacement 0xcdcdcdd5), mais je ne parviens vraiment pas à comprendre pourquoi :/
L'appel qui fait que ça casse tout
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 _stateManager->setRightHandState(tracking);StateManager.hpp :
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 #include "StateManager.hpp" StateManager::StateManager(void) { _leftHandState = no_fingers; _rightHandState = no_fingers; } StateManager::~StateManager(void) {} void StateManager::setLeftHandState(const FingerState state) { _leftHandState = state; } // La méthode qui fait tout péter void StateManager::setRightHandState(const FingerState state) { _rightHandState = state; } FingerState StateManager::getLeftHandState() const { return _leftHandState; } FingerState StateManager::getRightHandState() const { return _rightHandState; } void StateManager::act() const { }
FingerState.hpp
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 #ifndef STATEMANAGER_HPP_INCLUDED #define STATEMANAGER_HPP_INCLUDED #include "Singleton.hpp" #include "FingerState.hpp" class StateManager : public Singleton<StateManager> { friend class Singleton<StateManager>; private: StateManager(void); virtual ~StateManager(void); public: void setLeftHandState(const FingerState state); void setRightHandState(const FingerState state); FingerState getLeftHandState() const; FingerState getRightHandState() const; void act() const; protected: FingerState _leftHandState; FingerState _rightHandState; }; #endif // STATEMANAGER_HPP_INCLUDED
Singleton.hpp
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 #ifndef FINGERSTATE_HPP_INCLUDED #define FINGERSTATE_HPP_INCLUDED enum FingerState { // Both no_fingers, // Right Hand tracking, zooming, shooting, scrolling, zoomShooting, // Left Hand moving }; #endif // FINGERSTATE_HPP_INCLUDED
Voila, si vous avez quelques pistes je suis preneur !
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 #ifndef SINGLETON_HPP_INCLUDED #define SINGLETON_HPP_INCLUDED #include <stdlib.h> template <typename T> class Singleton { protected: // Constructeur/destructeur Singleton () { } ~Singleton () { } public: // Interface publique static T *getInstance () { if (NULL == _singleton) { _singleton = new T; } return (static_cast<T*> (_singleton)); } static void kill () { if (NULL != _singleton) { delete _singleton; _singleton = NULL; } } private: // Unique instance static T *_singleton; }; template <typename T> T *Singleton<T>::_singleton = NULL; #endif // SINGLETON_HPP_INCLUDED
Merci d'avance
Zouch-K
Partager