1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   System Management (System)                                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_system.h"
29 #include "gx_utility.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_system_all_views_free                           PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function releaes the views attached to the given root window   */
45 /*    and it's chilren back to the free list.                             */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    root                                  Root window that needs to     */
50 /*                                            have it's views released    */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    views owned by this root and children are returned to free list     */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*     _gx_system_views_free                Free views for one window     */
59 /*     _gx_system_error_process             Process error code            */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    GUIX Internal Code                                                  */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_gx_system_all_views_free(GX_WINDOW_ROOT * root)74 VOID _gx_system_all_views_free(GX_WINDOW_ROOT *root)
75 {
76 #ifndef GX_DISABLE_ERROR_CHECKING
77 int viewcount;
78 #endif
79 
80 GX_VIEW   *test;
81 GX_WIDGET *child;
82 GX_WINDOW *win;
83 
84     /* pick up pointer to first child window */
85     child = root -> gx_widget_first_child;
86 
87     /* free each of the top-level window's views */
88     while (child)
89     {
90         if (child -> gx_widget_type >= GX_TYPE_WINDOW)
91         {
92             win = (GX_WINDOW *)child;
93             test = win -> gx_window_views;
94 
95             /* does this window have any views? */
96 
97             if (test)
98             {
99                 _gx_system_views_free(test);
100                 win -> gx_window_views = GX_NULL;
101             }
102         }
103         child = (child -> gx_widget_next);
104     }
105 
106 
107     /* lastly, free the root window's views */
108 
109     test = root -> gx_window_views;
110 
111     if (test)
112     {
113         _gx_system_views_free(test);
114         root -> gx_window_views = GX_NULL;
115     }
116 
117 #ifndef GX_DISABLE_ERROR_CHECKING
118     test = _gx_system_free_views;
119 
120     viewcount = 0;
121 
122     while (test)
123     {
124         viewcount++;
125         test = test -> gx_view_next;
126     }
127 
128     if (viewcount != GX_MAX_VIEWS)
129     {
130         _gx_system_error_process(GX_SYSTEM_OUT_OF_VIEWS);
131     }
132 #endif
133 }
134 
135