Objective Grid: Problem with constructors being called before GXInit()

Article ID: 444
Last updated: 27 Apr, 2018
Article ID: 444
Last updated: 27 Apr, 2018
Revision: 3
Views: 2872
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 27 Apr, 2018
by Meltreger B.

Problem

 


Problem with constructors being called before GXInit()

 

 


Cause

 


 

 


Action

 


There is a problem if the CGXGridParam constructor is called and the GXInit() method has not been called. This can happen if you embed a grid window into a dialog-only app. The dialog class is constructed before the InitInstance() method is called.

We added the following ASSERT in the CGXGridParam, CGXGridCore, and CGXProperties constructors along with a suggestion of how to work around the problem.
 

CGXGridCore::CGXGridCore(CWnd* pGridWnd, CDocument* pGridDoc, BOOL bIsViewContext)
{
m_pAppData = GXGetAppData();

ASSERT(m_pAppData->m_bInitDone);
// ASSERTION-> This constructor is called before the GXInit()
// method has been called. This can be problematic because
// at this time no factory object is available.
//
// Make sure you didn't simply forget to call GXInit() from
// your application's InitInstance method. 
//
// Another reason for this problem can be that the object is 
// constructed at the same time that your application object 
// is instantiated, for example if you embedded this class 
// as member variable in the application class. 
// 
// To resolve the problem, we recommend you instantiate the
// object on the heap. Change your class declaration and
// declare a pointer to this class. After GXInit() has been
// called you can call m_pGrid = new CGXGridCore. In your
// class destructor don't forget to delete m_pGrid.
// ->END

}


 

This article was:   Helpful | Not helpful
Report an issue
Article ID: 444
Last updated: 27 Apr, 2018
Revision: 3
Views: 2872
Posted: 12 Jan, 2001 by Meltreger B.
Updated: 27 Apr, 2018 by Meltreger B.

Others in this category