TheoraVideoManager不会在0x7329E13D(msvcr110.dll)初始化未处理的异常

时间:2013-08-10 23:39:37

标签: c++ ogg-theora

我似乎有一个问题,我继续得到一个未处理的异常异常,因为TheoraVideoManager没有初始化基本上我在Win32Project1.exe中的0x7329E13D(msvcr110.dll)得到未处理异常:0xC0000005:访问冲突读取位置0x00194000。 / p>

这是我在做什么

#include <theoraplayer/TheoraPlayer.h>
#include <theoraplayer/TheoraDataSource.h>
#include "theoraplayer/TheoraVideoManager.h"
TheoraVideoManager *mgr ;

/////////////////////////////////

void  init(void)
{
mgr=new TheoraVideoManager();
char* x="one.ogg";
Texttemp=new THVideo(x);
}

////////////

Video.h
extern TheoraVideoManager *mgr ;

//////////////

    THVideo(char* File){        
  ///// crashes here on clip
        clip=mgr->createVideoClip(new TheoraMemoryFileDataSource(File));
        clip->setAutoRestart(1);
        clip->pause();
        texture->texID=createTexture(nextPow2(clip->getWidth()),nextPow2(clip->getHeight()), textureFormat);

    }

/////////////////////////////

1 个答案:

答案 0 :(得分:3)

如果你使用的指针初始化为不同的NULL,你的代码就不会小心了。因此,如果在管理器初始化或剪辑初始化时出现错误,则使用指针并在没有更多详细信息的情况下崩溃。

首先将管理器声明为具有空值的静态。

TheoraVideoManager *mgr = NULL;

现在假设THVideo是一个类,该剪辑是数据成员。 在你的所有代码中检查指针是否如下所示不为null并在出现错误时抛出异常。

THVideo(const char* File){        
     if (mgr == NULL)
      { throw "null pointer";}

    clip=mgr->createVideoClip(new TheoraMemoryFileDataSource(File));
    if(clip == NULL)
     { throw "error on file data source" }

      .....
  }
相关问题