bug in CDocker::LoadRegistrySettings

Ben
2011-07-21
2013-05-28
  • Ben

    Ben - 2011-07-21

    Hi,

    In docking.h
    If there is no configuration in registry, the function

    inline BOOL CDocker::LoadRegistrySettings(tString tsRegistryKeyName)
    

    will cause an exception because bResult return false:

    if (!bResult) CloseAllDockers();
    

    CloseAllDockers() will call SetRedraw(FALSE);
    SetRedraw will call assert(::IsWindow(m_hWnd));
    but m_hWnd is NULL which will result an assertion.

    All dockers related samples have this bug.

    Best regards,
    Ben

     
  • David

    David - 2011-07-22

    Hi Ben,

    I'm having difficulty verifying this problem. Perhaps we are looking at different things.
    These are the steps I take to verify the problem.
    1) Use Regedit to delete the Win32++ registry entry in HKEY_CURRENT_USER/Software
    2) Run the Dock, DockContainer or DockTabbedMDI samples from version 7.1.3

    The samples run without throwing an exception, or any other indication of problems.

    Are you using version 7.1.3 of Win32++ and are you doing something like the above to verify a problem in LoadRegistrySettings?

    You also refer to a problem with the SetRedraw within CloseAllDockers.
    If this call fails with an assert at ::IsWindow(m_hWnd), that indicates that the view window of CMainFrame hasn't been successfully created (CMainFrame's view window is the dock ancestor). This view window is created before any attempt is made to read from the registry. The view window is created as part of CMainFrame::OnCreate, whereas the registry configuration is read in CMainFrame::OnInitialUpdate, which occurs later.

    Anyway, I'd like to get to the bottom of this issue, so please get back to me with some more information that might help pin it down.

    Best regards,
    David

     
  • Ben

    Ben - 2011-07-22

    Hi, David,

    I run the samples at my place.
    The os is windows xp sp3 and the IDE is VC6 sp6.
    Before I run these samples I update all source code from svn.
    I run lots of samples, especially the dockers related ones.
    Most of them crushed when I just compile and run them without any change.
    I trace them and find that most of them crushed because of the m_hWnd is NULL which results in an assertion.
    Before I sleep, I update the source code again, only one file wincore.h has been changed:

    Revision 1585:

    #ifdef _WIN32_WCE
                m_hWnd = ::CreateWindowEx(dwExStyle, ClassName, lpszWindowName, dwStyle, x, y, nWidth, nHeight,
                                        hWndParent, 0, GetApp()->GetInstanceHandle(), lpParam);
    #else
        //      HMENU hMenu = pMenu? pMenu->GetHandle() : NULL;
        //      m_hWnd = ::CreateWindowEx(dwExStyle, ClassName, lpszWindowName, dwStyle, x, y, nWidth, nHeight,
        //                              hWndParent, hMenu, GetApp()->GetInstanceHandle(), lpParam);
    #endif
    

    Current Version: 1586

    #ifdef _WIN32_WCE
                m_hWnd = ::CreateWindowEx(dwExStyle, ClassName, lpszWindowName, dwStyle, x, y, nWidth, nHeight,
                                        hWndParent, 0, GetApp()->GetInstanceHandle(), lpParam);
    #else
                HMENU hMenu = pMenu? pMenu->GetHandle() : NULL;
                m_hWnd = ::CreateWindowEx(dwExStyle, ClassName, lpszWindowName, dwStyle, x, y, nWidth, nHeight,
                                        hWndParent, hMenu, GetApp()->GetInstanceHandle(), lpParam);
    #endif
    

    and I find that only dockers related programs would crush, others wouldn't.

    Today I have just updated all source code from svn at my office.
    And I do the same thing I did yesterday night at my home.
    The OS is windows xp sp2 and the IDE is vs2008 professional.
    No problems found. The dockers related programs are all OK.
    I don't know why. Maybe my OS has some problems or other kind of things.

    Best regards,
    Ben

     
  • Ben

    Ben - 2011-07-22

    Hi,

    I will test again after I go home tonight and to see if the problems still exist.
    I think most of the programs crushed because the line

    HMENU hMenu = pMenu? pMenu->GetHandle() : NULL;
                m_hWnd = ::CreateWindowEx(dwExStyle, ClassName, lpszWindowName, dwStyle, x, y, nWidth, nHeight,
                                        hWndParent, hMenu, GetApp()->GetInstanceHandle(), lpParam);
    

    is commented which result in the m_hWnd is always NULL.

    Whether the dockers crushed are related to the registry I will test again tonight and tell you the result.

    Best regards,
    Ben

     
  • David

    David - 2011-07-22

    Hi Ben,

    Yes that makes more sense now. SVN Version 1585 mistakenly commented the CreateWindowEx within CWnd::CreateEx. SVN Version 1586 fixed that. I expect the problems you experienced were caused by this, and were unrelated to the use of the registry. As it happens I was fixing a WinCE compatibility issue and forgot to uncomment these lines before the SVN update.

    I should mention that code available via SVN is "work in progress" code. While I make reasonable efforts to ensure that this code is bug free, it is not well tested (unlike the official releases), and problems like this can occur.

    By all means use the code from SVN if you wish, and let me know if you notice problems. Just be aware that the SVN code might have bugs or features that are only partially implemented.

    Best regards,
    David

     
  • Ben

    Ben - 2011-07-22

    Hi, David

    I just test the samples again. No problems found.
    So I think all problems can attribute to the comment line code.
    Thanks for your hard work on win32++.

    Best regards,
    Ben

     

Log in to post a comment.