Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Access Violation?

Access Violation?

Scheduled Pinned Locked Moved C / C++ / MFC
c++csscomtoolshelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BlackDice
    wrote on last edited by
    #1

    I have a grid (Chris Maunder's MFC Grid) on a formview in one pane of a CSplitterWnd object. The formview has a function called Refresh(). Inside of Refresh(), I call a function of the grid (SetRowCount(1)). Within SetRowCount() it checks to see if 'rows' that I sent in is equal to GetRowCount() like so: ASSERT(nRows >= 0); if (nRows == GetRowCount()) return bResult;This works fine when Refresh is called from anywhere else within the form itself. The Refresh() function is public and from another pane I get the CMainFrame* (which has a pointer to the Form that has the grid) and I call the Refresh() function and I get an Access Violation error on this line: int GetRowCount() const { return m_nRows; } which is being called from the code above in SetRowCount(). Does anyone have any idea what the ^&*( is going on? Thanks,

    My Music | My Pics | My Articles BlackDice

    C J B 3 Replies Last reply
    0
    • B BlackDice

      I have a grid (Chris Maunder's MFC Grid) on a formview in one pane of a CSplitterWnd object. The formview has a function called Refresh(). Inside of Refresh(), I call a function of the grid (SetRowCount(1)). Within SetRowCount() it checks to see if 'rows' that I sent in is equal to GetRowCount() like so: ASSERT(nRows >= 0); if (nRows == GetRowCount()) return bResult;This works fine when Refresh is called from anywhere else within the form itself. The Refresh() function is public and from another pane I get the CMainFrame* (which has a pointer to the Form that has the grid) and I call the Refresh() function and I get an Access Violation error on this line: int GetRowCount() const { return m_nRows; } which is being called from the code above in SetRowCount(). Does anyone have any idea what the ^&*( is going on? Thanks,

      My Music | My Pics | My Articles BlackDice

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      before you make that call to GetRowCount, what does the pointer to the Grid look like ? is it the same value you see when you call Grid functions that don't cause AVs ? cause, that sounds a bit like a bogus pointer problem...

      image processing | blogging

      1 Reply Last reply
      0
      • B BlackDice

        I have a grid (Chris Maunder's MFC Grid) on a formview in one pane of a CSplitterWnd object. The formview has a function called Refresh(). Inside of Refresh(), I call a function of the grid (SetRowCount(1)). Within SetRowCount() it checks to see if 'rows' that I sent in is equal to GetRowCount() like so: ASSERT(nRows >= 0); if (nRows == GetRowCount()) return bResult;This works fine when Refresh is called from anywhere else within the form itself. The Refresh() function is public and from another pane I get the CMainFrame* (which has a pointer to the Form that has the grid) and I call the Refresh() function and I get an Access Violation error on this line: int GetRowCount() const { return m_nRows; } which is being called from the code above in SetRowCount(). Does anyone have any idea what the ^&*( is going on? Thanks,

        My Music | My Pics | My Articles BlackDice

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #3

        BlackDice wrote:

        Does anyone have any idea what the ^&*( is going on?

        Is this NULL or a dangling/invalid pointer? Sounds like it...

        -- Secreted by the Comedy Bee

        1 Reply Last reply
        0
        • B BlackDice

          I have a grid (Chris Maunder's MFC Grid) on a formview in one pane of a CSplitterWnd object. The formview has a function called Refresh(). Inside of Refresh(), I call a function of the grid (SetRowCount(1)). Within SetRowCount() it checks to see if 'rows' that I sent in is equal to GetRowCount() like so: ASSERT(nRows >= 0); if (nRows == GetRowCount()) return bResult;This works fine when Refresh is called from anywhere else within the form itself. The Refresh() function is public and from another pane I get the CMainFrame* (which has a pointer to the Form that has the grid) and I call the Refresh() function and I get an Access Violation error on this line: int GetRowCount() const { return m_nRows; } which is being called from the code above in SetRowCount(). Does anyone have any idea what the ^&*( is going on? Thanks,

          My Music | My Pics | My Articles BlackDice

          B Offline
          B Offline
          BlackDice
          wrote on last edited by
          #4

          I found out what it was. I've got 5 different panes that all call back to CMainFrame with functions like SetLeftView(), SetRightView(), etc. I called SetRightView() instead of SetLeftView(), but I'm surprised it even made it that far. Thanks,

          My Music | My Pics | My Articles BlackDice

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups