Menu

MFC Doc-View problem

Help
Gary
2002-10-22
2002-10-23
  • Gary

    Gary - 2002-10-22

    If I call the CDocument::UpdateAllViews in a TestFixture the MFC code ASSERTs in
    ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL ||
        (p = pMap->LookupTemporary(m_hWnd)) != NULL);
    I'm as sure as I can be that the window being called from the CDocument is valid so I'm not sure what is going on. Note that if UpdateAllViews gets called from outside the TestFixture, in the normal course of running the program, everything is fine.

    Microsoft kindly commented the above ASSERTs with this:
    // Note: if either of the above asserts fire and you are
    // writing a multithreaded application, it is likely that
    // you have passed a C++ object from one thread to another
    // and have used that object in a way that was not intended.
    // (only simple inline wrapper functions should be used)
    //
    // In general, CWnd objects should be passed by HWND from
    // one thread to another.  The receiving thread can wrap
    // the HWND with a CWnd object by using CWnd::FromHandle.
    //
    // It is dangerous to pass C++ objects from one thread to
    // another, unless the objects are designed to be used in
    // such a manner.

    Does that make any sense? Is the test code running in a different thread?

     
    • Gary

      Gary - 2002-10-23

      Sorry, I missed out an important fact - the file in which it asserts is WINCORE.CPP, lines 882-883.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.