C ++代码仅在从终端运行程序时执行

时间:2011-05-19 16:07:31

标签: c++ ogre

我有一个奇怪的错误,只有当程序没有从终端执行时才会出现。这是我的项目: https://github.com/elliotpotts/Troll/ https://github.com/elliotpotts/Troll/issues/2

查看Troll::State::keyPressed()函数。出于某种原因,当我从终端运行程序时,一切都很好并且应用程序存在但是当我将其作为GUI程序运行时,应用程序不会退出。我想不出为什么。先谢谢你,

编辑:抱歉没有添加Ogre标签而没有发布keyPressed功能,这里是:

void Troll::State::keyPressed(const OIS::KeyEvent& event){
    if(event.key == OIS::KC_Q) {
        mCreator->stop();
    };
};

我还尝试添加文件输出来测试它:

void Troll::State::keyPressed(const OIS::KeyEvent& event){
    std::cout << "Q was pressed" << std::endl;
    std::fstream file("log");
    file << "Q was pressed";
    file.close();
    if(event.key == OIS::KC_Q) {
        mCreator->stop();
    };
};

从终端运行时,这是有效的,否则,它不起作用。另外一点,我目前还没有一个功能正常的调试器,我也在努力解决这个问题。埃尔。

1 个答案:

答案 0 :(得分:0)

事实证明这是导致问题的IDE,无论如何,感谢你的帮助,嗯:)