2

我似乎有一个问题,由于 TheoraVideoManager 没有初始化,我一直收到未处理的异常异常,我在 Win32Project1.exe 中的 0x7329E13D (msvcr110.dll) 处收到未处理的异常:0xC0000005:访问冲突读取位置 0x00194000。

这就是我的做法

#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);

    }

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

4

1 回答 1

3

如果您使用的指针初始化为具有不同的 NULL,则您的代码不会注意。因此,如果在您的管理器初始化或剪辑初始化时出现问题,您将使用指针并在没有更多详细信息的情况下崩溃。

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

TheoraVideoManager *mgr = NULL;

现在假设 THVideo 是一个类,并且该剪辑是一个数据成员。在您的所有代码中检查指针是否像下面那样为空,如果出现问题则抛出异常。

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" }

      .....
  }
于 2013-08-14T16:27:47.880 回答