在我的程序中,此代码崩溃:
#ifndef SOUNDBOARD_H
#define SOUNDBOARD_H
#include "main.h"
struct Sound
{
Sound(short &SR, short &SSC, short &SL){
SoundRow=SR;
SoundStartColumn=SSC;
SoundLength=SL;
}
short SoundRow;//0 to 3 (Height, 4 rows on the soundboard)
short SoundStartColumn;//The X value on the soundboard (Can really be anything, as it keeps going right) NOTE: This is the point where the sound starts.
short SoundLength;//How long the sound is (How many cells it takes up) 1-5 (I believe 5 is the largest sound, which is 10 seconds, as each cell is 2 seconds)
bool SoundPlaying=false;//Is the sound playing?
};
class Frame;
class SoundBoard
{
public:
SoundBoard(Frame& MainFrameRef_);
virtual ~SoundBoard();
Frame& MainFrameRef;
void Step();
void ButtonStep();
void CreateSound();
sf::Sprite* SaveMp3ButtonPressed;
sf::Sprite* LoadButtonPressed;
sf::Sprite* SaveButtonPressed;
sf::Sprite* StopButtonPressed;
sf::Sprite* PlayButtonPressed;
sf::Sprite* PauseButtonPressed;
sf::Sprite* PauseButton;
sf::Sprite* ClearButtonPressed;
sf::RenderTexture SoundBoardRender;
vector<vector<int>> SoundsMap;//y, x (So that x can be a different height per row.)
vector<Sound> BoardSounds;
void SBStop();
void SBPlay();
void SBPause();
void SBClear();
void SBSave();
void SBLoad();
void SBSaveMp3();
//Left and right scroller images.
protected:
private:
};
#endif // SOUNDBOARD_H
但是,在公共部分中移动一个变量可以修复它。像这样:
SoundBoard(Frame& MainFrameRef_);
virtual ~SoundBoard();
Frame& MainFrameRef;
void Step();
void ButtonStep();
void CreateSound();
sf::Sprite* SaveMp3ButtonPressed;
sf::Sprite* LoadButtonPressed;
sf::Sprite* SaveButtonPressed;
sf::Sprite* StopButtonPressed;
sf::Sprite* PlayButtonPressed;
sf::Sprite* PauseButtonPressed;
sf::Sprite* PauseButton;
sf::Sprite* ClearButtonPressed;
vector<vector<int>> SoundsMap;//y, x (So that x can be a different height per row.)
sf::RenderTexture SoundBoardRender;
vector<Sound> BoardSounds;
void SBStop();
void SBPlay();
void SBPause();
void SBClear();
void SBSave();
void SBLoad();
void SBSaveMp3();
//Left and right scroller images.
我不确定发生了什么,我放弃了尝试自己修复它:/ (在上面的代码中,我感动了:
vector<vector<int>> SoundsMap
向上一行)
我正在尝试使用GIT来管理我的源代码,虽然可能不是必需的,这可能是由于旧版本和新版本的文件混淆并破坏了吗?
编辑:重建项目,并确保GIT中没有待处理的更改似乎解决了问题(可能是第一个,而不是第二个) 所以这是固定的,所以这个问题更多的是'为什么会发生这种情况,以及如何避免'我猜想。