Author Topic: browser tracker issue on record position number  (Read 7462 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
browser tracker issue on record position number
« on: January 03, 2012, 09:15:34 am »
I have tracked the source code, and found that:
Code
// ----------------------------------------------------------------------------
void JumpTracker::JumpDataAdd(const wxString& filename, const long posn, const long lineNum)
// ----------------------------------------------------------------------------
{
    // Do not record old jump locations when a jump is in progress
    // Caused by activating an editor inside the jump routines
    if (m_bJumpInProgress)
        return;

    // Dont record position if line number is < 1 since a newly loaded
    // file always reports an event for line 0
     if (lineNum < 1)       // user requested feature 2010/06/1
     {
        return;
     }

    // if current entry is identical, return
    if (m_Cursor == JumpDataContains(filename, posn))
        return;

    // record new jump entry
    size_t count = m_ArrayOfJumpData.GetCount();
    m_Cursor += 1;
    if ( m_Cursor > maxJumpEntries-1 )
        m_Cursor = 0;

    #if defined(LOGGING)
    LOGIT( _T("JT JumpDataAdd[%s][%ld][%d]"), filename.c_str(), posn, m_Cursor);
    #endif

    do {
        if ( count <= (size_t)m_Cursor )
        {   //initialize new item
            m_ArrayOfJumpData.Add(new JumpData(filename, posn));
            //return;
            break;
        }

        JumpData& jumpData = m_ArrayOfJumpData.Item(m_Cursor);
        jumpData.SetFilename( filename );
        jumpData.SetPosition(  posn );
        break;
    }while(0);

    #if defined(LOGGING)
    wxCommandEvent evt;
    OnMenuJumpDump(evt);
    #endif
    return;
}

Here what is the logic of generate the m_Cursor?

I just enabled the debug logging, and found that if I just click on the editor header to activate the editor( not click on the editor content), then the m_Cursor is the position which does not belong to the current vision range?

Any one can explain this? (because I always meet an issue that when I jump back to some place I have never click on)

Thanks.
« Last Edit: January 03, 2012, 09:20:25 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: browser tracker issue on record position number
« Reply #1 on: January 07, 2012, 01:52:06 pm »
I looked it further, and found that it do have some issue:

1, suppose that I have A.cpp and A.h
2, Now, Menu->View->Jump->Jump clear
3, navigate in A.h, so the Jump position was recorded correctly.
4, right click on a function declaration, and select "goto definition"
5, Now, you have goto A.cpp.

Here comes the bug:
Now, by looking at the debug trace output in BrowseTracker, two jump position of A.cpp was recorded.
One is the position when the A.cpp is activated(the BrowserTracker record one position), I call it PositionA.
The next one is the function body position in A.cpp, I call it PositionB.

Now, I click the "jump backward", the caret will first return to "PositionA" in the same source file (A.cpp), then click "jump backward" again I will return to A.h.

From my point of view, we should NOT record the "PositionA"., so that we can only click "jump backward" once to return to the function declaration in A.h.

Any ideas. :)

Edit


I simply comment out the line:
Code
 JumpDataAdd(edFilename, edPosn, edstc->GetCurrentLine());
In JumpTracker.cpp, OnEditorActivated function body, I think we do not need to record jump position there.
« Last Edit: January 07, 2012, 02:15:23 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2775
Re: browser tracker issue on record position number
« Reply #2 on: January 08, 2012, 11:55:44 am »
Thanks, I'll have a look at this.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2775
Re: browser tracker issue on record position number
« Reply #3 on: January 11, 2012, 04:57:35 pm »
Here's a patch that records only the de-activated editor position(rather than the new editor activated position).

There may be at least one position in the stack on which you have not clicked.

The extra position is placed there so that you may return to the last position of the de-activated editor.

Give it a try.

 
« Last Edit: January 11, 2012, 04:59:20 pm by Pecan »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: browser tracker issue on record position number
« Reply #4 on: January 12, 2012, 01:04:27 am »
Here's a patch that records only the de-activated editor position(rather than the new editor activated position).

There may be at least one position in the stack on which you have not clicked.

The extra position is placed there so that you may return to the last position of the de-activated editor.

Give it a try.
 
Thank you very much!
I will test your patch in the weekend. (I'll have a travel right now)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: browser tracker issue on record position number
« Reply #5 on: January 15, 2012, 10:02:39 am »
Test the patch and works fine!!! :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.