Hi Experts,
We have a legacy MFC SDI application which is ~15year old. Currently it is getting built using VC14 runtime. Recently we noticed one issue where the application started failing to launch with error dialog "failed to create empty document". Application only fails to load when the UI language is non-English. I have checked and ensured there are no changes done from past 1 year to this code base.
This is where the error dialog comes from:
The CWinApp child class <MyApplication>App class's InitInstance() ProcessShellCommand(cmdInfo) shows "failed to create empty document" error and application fails to launch in Japanese and Chinese languages and it works fine with English.
Edit:
Some more info after Jeanine inputs:
Thank you for the detailed explanation Jeanine.
With the help of your answer, I further debugged the code and isolated the problem area. Following is the flow in working condition and failure.
Q_DISMAINFRAME_CLASS::PreCreateWindow seems to be getting called twice in a normal case where as in a failure case, Q_DISMAINFRAME_CLASS::PreCreateWindow is not getting called the second time. I made sure that the code related to this app is not changed between last working version and now. Isolating the system software environment is a huge task knowing my MFC limited knowledge.
Any help is much appreciated.
Failed case: System language set to Dutch
P_GENUI_WINAPP_CLASS::InitInstance() start
cmd_line_param_ptr: (null)
Before calling ProcessShellCommand
Q_DISDOC_CLASS::Q_DISDOC_CLASS() start
before configure
After configure()
Q_DISDATABUFFER_CLASS::Q_DISDATABUFFER_CLASS start
Q_DISDATABUFFER_CLASS::Q_DISDATABUFFER_CLASS end
Q_DISDOC_CLASS::Q_DISDOC_CLASS() exit
P_GENUI__FRAME_BASE_CLASS::STACKING_ORDER_STRUCT::STACKING_ORDER_STRUCT()
P_GENUI__FRAME_BASE_CLASS::P_GENUI__FRAME_BASE_CLASS() start
P_GENUI__FRAME_BASE_CLASS::retrieve_stacking_order() start
P_GENUI__FRAME_BASE_CLASS::retrieve_stacking_order() end
ERROR_SUCCESS == ret_val : 1
P_GENUI__FRAME_BASE_CLASS::P_GENUI__FRAME_BASE_CLASS() end
Q_DISMAINFRAME_CLASS::Q_DISMAINFRAME_CLASS()
Q_DISMAINFRAME_CLASS::PreCreateWindow start
P_GENUI__FRAME_BASE_CLASS::set_createstruct
P_GENUI__FRAME_BASE_CLASS::set_createstruct - success: 1
lpszClass: AfxFrameOrView140u
lpszName: (null)
cx: -2147483648
cy: -2147483648
wExStyle: 512
style: 0
x: 0
y: 0
Q_DISMAINFRAME_CLASS::PreCreateWindow end
return_value: 1
I get "Failed to create empty document" error here
Working case : System language set to EN
P_GENUI_WINAPP_CLASS::InitInstance() start
cmd_line_param_ptr: (null)
Before calling ProcessShellCommand
Q_DISDOC_CLASS::Q_DISDOC_CLASS() start
before configure
After configure()
Q_DISDATABUFFER_CLASS::Q_DISDATABUFFER_CLASS start
Q_DISDATABUFFER_CLASS::Q_DISDATABUFFER_CLASS end
Q_DISDOC_CLASS::Q_DISDOC_CLASS() exit
P_GENUI__FRAME_BASE_CLASS::STACKING_ORDER_STRUCT::STACKING_ORDER_STR
P_GENUI__FRAME_BASE_CLASS::P_GENUI__FRAME_BASE_CLASS() start
P_GENUI__FRAME_BASE_CLASS::retrieve_stacking_order() start
P_GENUI__FRAME_BASE_CLASS::retrieve_stacking_order() end
ERROR_SUCCESS == ret_val : 1
P_GENUI__FRAME_BASE_CLASS::P_GENUI__FRAME_BASE_CLASS() end
Q_DISMAINFRAME_CLASS::Q_DISMAINFRAME_CLASS()
Q_DISMAINFRAME_CLASS::PreCreateWindow start
P_GENUI__FRAME_BASE_CLASS::set_createstruct
P_GENUI__FRAME_BASE_CLASS::set_createstruct - success: 1
lpszClass: AfxFrameOrView140u
lpszName: (null)
cx: -2147483648
cy: -2147483648
wExStyle: 512
style: 0
x: 0
y: 0
Q_DISMAINFRAME_CLASS::PreCreateWindow end
return_value: 1
Q_DISMAINFRAME_CLASS::PreCreateWindow start
P_GENUI__FRAME_BASE_CLASS::set_createstruct
P_GENUI__FRAME_BASE_CLASS::set_createstruct - success: 1
lpszClass: Afx:00F00000:b:00010003:00000006:00010643
lpszName: DisplayApp
cx: -2147483648
cy: -2147483648
wExStyle: 512
style: 0
x: -2147483648
y: -2147483648
Q_DISMAINFRAME_CLASS::PreCreateWindow end
return_value: 1
Q_DISMAINFRAME_CLASS::OnCreate start
Q_DISSIGNAL_COMBI_BOX_CLASS::Q_DISSIGNAL_COMBI_BOX_CLASS() start
Q_DISSIGNAL_COMBI_BOX_CLASS::Q_DISSIGNAL_COMBI_BOX_CLASS() end
Q_DISDVIEW_CLASS::Q_DISDVIEW_CLASS() start
Q_DISDVIEW_CLASS::Q_DISDVIEW_CLASS() exit
Q_DISMAINFRAME_CLASS::OnCreate end
Q_DISDVIEW_CLASS::OnInitialUpdate()
Q_DISDVIEW_CLASS::DoDataExchange start
Q_DISDVIEW_CLASS::DoDataExchange end