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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
Sorry, I missed out an important fact - the file in which it asserts is WINCORE.CPP, lines 882-883.