Menu

#278 Error in atlsplit.h?

v1.0 (example)
closed-duplicate
None
5
2015-09-25
2015-09-25
Anonymous
No

I think there is an error if atlsplit.h ( WTL90_4140-613 ) that behaves as follows:

  1. The default split position is set by SetSplitterDefaultPosPct(50).
  2. The split position is set by SetSplitterPosPct(50).
  3. I change the split position with the mouse.
  4. From a popup menu event I call SetSplitterPos() (default parameters (-1)).
  5. The split position is now moved to 50% as expected.
  6. I open the context menu a second time, but select nothing - clicks outside to close it.
  7. I now receives a OnCaptureChanged() event in CSplitterImpl (atlsplit.h line 670).
  8. In line 675 the code is like this;
    if(!m_bFullDrag || (m_xySplitterPos != m_xySplitterPosNew))
    m_bFullDrag is true and m_xySplitterPos is not equal to m_xySplitterPosNew
    so the braced code is called.
  9. The split position now jumps back to the position before (5).

I think the bug is in SetSplitterPos(). The m_xySplitterPos is changed, but m_xySplitterPosNew is left unchanged. When a WM_CAPTURECHANGED is received (for some unknown reason) OnCaptureChanged() thinks a move is going on.
By changing the SetSplitterPos(), line 168, from m_xySplitterPos = xyPos; to m_xySplitterPosNew = m_xySplitterPos = xyPos; the error disappears.

I have not been able to reproduce the error in a simple test application because I do not receive the WM_CAPTURECHANGED event there. My app contains multiple nested splitters and panes with list view controls, browser control e.t - too complicate to reproduce in a test app. I do not know why the WM_CAPTURECHANGED is fired when the menu closes in my app.

What you must consider is: Does it create side effects if the m_xySplitterPosNew is set equal to m_xySplitterPos in SetSplitterPos()?

From code m_xySplitterPosNew has the comment “internal - new position while moving”. So it’s only used while dragging the splitter bar (?).

Anyway, I have not experienced any abnormal behavior after changing the code as indicated.

Thanks for WTL
Ottar Arne

Discussion

  • Nenad Stefanovic

    • status: open --> closed-duplicate
     
  • Nenad Stefanovic

    This is a duplicate of the bug #272

    Fixed in atlsplit.h, rev 621

     

Anonymous
Anonymous

Add attachments
Cancel