arch/sim: Fix NXWM test failure

## Summary of changes

Fixed the crash caused by a NULL memory access to an invalid background
window.

Signed-off-by: Sebastian Ene <sene@apache.org>
This commit is contained in:
Sebastian Ene 2020-10-31 13:55:10 +02:00 committed by Brennan Ashton
parent fcc485cc7a
commit fce08ec029
2 changed files with 22 additions and 4 deletions

View File

@ -70,7 +70,7 @@ using namespace NxWM;
CTaskbar::CTaskbar(void)
{
m_taskbar = (NXWidgets::CNxWindow *)0;
m_background = (NXWidgets::CNxWindow *)0;
m_background = (NXWidgets::CBgWindow *)0;
m_backImage = (NXWidgets::CImage *)0;
m_topApp = (IApplication *)0;
m_started = false;
@ -163,7 +163,7 @@ void CTaskbar::disconnect(void)
// Then delete the background
delete m_background;
m_background = (NXWidgets::CNxWindow *)0;
m_background = (NXWidgets::CBgWindow *)0;
}
// Delete the background image
@ -972,9 +972,27 @@ bool CTaskbar::createTaskbarWindow(void)
bool CTaskbar::createBackgroundWindow(void)
{
CWindowMessenger *control = new CWindowMessenger((NXWidgets::CWidgetStyle *)NULL);
// Create a raw window to present the background image
m_background = openRawWindow();
NXWidgets::CBgWindow *background = getBgWindow(control);
if (!background)
{
delete control;
return false;
}
// Open (and initialize) the BG window
bool success = background->open();
if (!success)
{
delete background;
return false;
}
m_background = background;
if (!m_background)
{
return false;

View File

@ -101,7 +101,7 @@ namespace NxWM
*/
NXWidgets::CNxWindow *m_taskbar; /**< The task bar window */
NXWidgets::CNxWindow *m_background; /**< The background window */
NXWidgets::CBgWindow *m_background; /**< The background window */
NXWidgets::CImage *m_backImage; /**< The background image */
IApplication *m_topApp; /**< The top application in the hierarchy */
TNxArray<struct STaskbarSlot> m_slots; /**< List of application slots in the task bar */