Debug Assertion Failed! ARGH! NOT AGIAN!! lol

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SorceCode

    Debug Assertion Failed! ARGH! NOT AGIAN!! lol

    Hey guys, good old
    [color=blue]
    > Debug Assertion Failed!
    > File: dbgdel.cpp
    > Line: 47
    > Expression: _BLOCK_TYPE_IS_ VALID(pHead->nBlockUse)[/color]

    Rears its ugly head agian!

    Ok heres what Im up to..

    DirectX 9.0
    C++
    Nuff said lol

    <Snippit>

    class w_DXObject
    {
    public:
    LPD3DXMESH Mesh; // Our mesh object in sysmem
    D3DMATERIAL9* MeshMaterials; // Materials for our mesh
    LPDIRECT3DTEXTU RE9* MeshTextures; // Textures for our mesh
    DWORD NumMaterials; // Number of mesh materials

    // Constructor
    w_DXObject()
    {
    Mesh = NULL;
    MeshMaterials = NULL;
    MeshTextures = NULL;
    NumMaterials = 0L;
    }

    // DeConstructor
    ~w_DXObject()
    {

    }

    void DestroyObject() ;
    bool LoadMesh(LPDIRE CT3DDEVICE9 Device, char* strFileName );
    bool Render(LPDIRECT 3DDEVICE9 Device);
    };

    void w_DXObject::Des troyObject()
    {
    // FIX ME!! MEMORY LEAK!!
    if( MeshMaterials != NULL )
    delete[] MeshMaterials; //throws here

    if( MeshTextures )
    {
    for( DWORD i = 0; i < NumMaterials; i++ )
    {
    if( MeshTextures[i] )
    MeshTextures[i]->Release();
    }
    delete[] MeshTextures; // and here
    }
    if( Mesh != NULL )
    {
    Mesh->Release();
    }
    }

    As you can see Im using class ref's of the things I am deleting.
    The MS File itself and most of the stuff I have read about this online
    show that I should only delete locals. No DLL's are involed in this
    prog.
    Based on DX9 AppWizard.

    Feel free to ask anything else.
    Thanks in advance guys!!
  • Victor Bazarov

    #2
    Re: Debug Assertion Failed! ARGH! NOT AGIAN!! lol

    "SorceCode" <sorcecode@hotm ail.com> wrote...[color=blue]
    > Hey guys, good old
    >[color=green]
    > > Debug Assertion Failed!
    > > File: dbgdel.cpp
    > > Line: 47
    > > Expression: _BLOCK_TYPE_IS_ VALID(pHead->nBlockUse)[/color]
    >
    > Rears its ugly head agian!
    >
    > Ok heres what Im up to..
    >
    > DirectX 9.0
    > C++
    > Nuff said lol
    >
    > <Snippit>
    >
    > class w_DXObject
    > {
    > public:
    > LPD3DXMESH Mesh; // Our mesh object in sysmem
    > D3DMATERIAL9* MeshMaterials; // Materials for our mesh
    > LPDIRECT3DTEXTU RE9* MeshTextures; // Textures for our mesh
    > DWORD NumMaterials; // Number of mesh materials
    >
    > // Constructor
    > w_DXObject()
    > {
    > Mesh = NULL;
    > MeshMaterials = NULL;
    > MeshTextures = NULL;
    > NumMaterials = 0L;
    > }
    >
    > // DeConstructor
    > ~w_DXObject()
    > {
    >
    > }
    >
    > void DestroyObject() ;
    > bool LoadMesh(LPDIRE CT3DDEVICE9 Device, char* strFileName );
    > bool Render(LPDIRECT 3DDEVICE9 Device);
    > };
    >
    > void w_DXObject::Des troyObject()
    > {
    > // FIX ME!! MEMORY LEAK!!
    > if( MeshMaterials != NULL )
    > delete[] MeshMaterials; //throws here
    >
    > if( MeshTextures )
    > {
    > for( DWORD i = 0; i < NumMaterials; i++ )
    > {
    > if( MeshTextures[i] )
    > MeshTextures[i]->Release();
    > }
    > delete[] MeshTextures; // and here
    > }
    > if( Mesh != NULL )
    > {
    > Mesh->Release();
    > }
    > }
    >
    > As you can see Im using class ref's of the things I am deleting.
    > The MS File itself and most of the stuff I have read about this online
    > show that I should only delete locals. No DLL's are involed in this
    > prog.
    > Based on DX9 AppWizard.
    >
    > Feel free to ask anything else.[/color]

    Let me ask: aren't OLE objects supposed to delete themselves when
    the last handle is released? If so, why are you 'delete'ing them?
    You just 'Release' them and be done, no?

    Anyway, if you don't know the answer to this question, we don't
    either because OLE and stuff like that is off-topic here. Try
    comp.os.ms-windows.program mer.win32 or any newsgroup with .ole.
    in it.
    [color=blue]
    > Thanks in advance guys!![/color]


    Comment

    • Christian Janßen

      #3
      Re: Debug Assertion Failed! ARGH! NOT AGIAN!! lol

      <snip>[color=blue]
      > void w_DXObject::Des troyObject()
      > {
      > // FIX ME!! MEMORY LEAK!!
      > if( MeshMaterials != NULL )
      > delete[] MeshMaterials; //throws here[/color]

      MeshMaterials = 0; // missing here
      [color=blue]
      >
      > if( MeshTextures )
      > {
      > for( DWORD i = 0; i < NumMaterials; i++ )
      > {
      > if( MeshTextures[i] )
      > MeshTextures[i]->Release();
      > }
      > delete[] MeshTextures; // and here[/color]

      MeshTextures = 0; // and here
      [color=blue]
      > }
      > if( Mesh != NULL )
      > {
      > Mesh->Release();
      > }
      > }[/color]

      </snip>


      Comment

      Working...