Strange behaviour on GUI_MEMDEV_Delete() function

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Strange behaviour on GUI_MEMDEV_Delete() function

    Hi all,

    I'm using emWin 5.18 on NXP LPC1788 device with gcc compiler.
    Sometimes I see that calling GUI_MEMDEV_Delete(memdev) causes HardFault_Handler(), that is microprocessor crash ..... It does not matter whether memdev was created or not before GUI_MEMDEV_Delete(memdev) call. It is not a problem due to memory overflow because often it happens when I call routine the first time.
    memdev is created with GUI_MEMDEV_CreateFixed() and normally it works properly.
    Just to try, I saw that it seems to work properly if I use WM_DeleteWindow(memdev) instead of GUI_MEMDEV_Delete(memdev)!!

    Any suggestions/info?

    Thanks and best regards,

    Valter Rasicci
  • Strange behaviour on GUI_MEMDEV_Delete() function

    Just for confirmation, look at this source code lines:


    GUI_MEMDEV_Handle md[5];


    /*THIS for CYCLE WORKS PERFECTLY (even though it is formally erroneous)!!*/
    for(i=0;i<5;i++)
    WM_DeleteWindow(md);




    /*THIS for CYCLE CAUSES microprocessor HardFault() (even though it is formally correct)!!*/
    for(i=0;i<5;i++)
    GUI_MEMDEV_Delete(md[i]);


    Best regards,

    Valter Rasicci
  • Questions MEMDEV managment and gcc toolchain

    Hi Adrian,

    sorry for my message that was not properly formatted. Please look at attached file containing considerations and source code.

    Best regards,

    Valter Rasicci
    Files
    • for_Adrian.pdf

      (307.66 kB, downloaded 1,471 times, last: )

    The post was edited 2 times, last by valterrasicci ().

  • Software hungs after calling of "WM_DeleteWindow"

    Hello Adrian,

    I have the problem that after the call of WM_DeleteWindow the software hungs!
    I don't want to use GUI_Delay as the code you can see in the attached file:
    How can i create and delete objects without delays?

    Thanks
    Armin
    Files
    • WM_Sample.zip

      (1.98 kB, downloaded 777 times, last: )
  • Application with EmWin hungs

    Hello Adrian,
    My Application with EMWin using hungs after of some oppening and closing of the Screen(the simpified code is to see as below), please write me what can i do, whereby the applcation can run stable?
    This problem is very important which appear by other users too, please write me all ways that you know to solve this problem.
    /************************************************************************************************************************************************************************/
    // Global variables
    static WM_HWIN m_Screen1=(GUI_HWIN)NULL;
    BUTTON_Handle m_Button1=(GUI_HWIN)NULL;
    /************************************************************************************************************************************************************************/
    // Event functions
    static void _cbScreen1(WM_MESSAGE * pMsg)
    {
    // Enable Antialiasing
    GUI_AA_EnableHiRes();
    // Set Antialiasing factor to maximal value
    GUI_AA_SetFactor(6);
    // Hide the cursor
    GUI_CURSOR_Hide();
    switch (pMsg->MsgId)
    {
    case WM_TOUCH:
    return;
    case WM_PID_STATE_CHANGED:
    break;
    case WM_KEY:
    break;
    case WM_PAINT:
    // Draw some Bitmaps and write texts on the screen with emWin-Functions GUI_DrawBitmap and GUI_DispStringInRectEx
    break;
    }
    }
    static void _cButton1(WM_MESSAGE * pMsg)
    {
    // Enable Antialiasing
    GUI_AA_EnableHiRes();
    // Set Antialiasing factor to maximal value
    GUI_AA_SetFactor(6);
    // Hide the cursor
    GUI_CURSOR_Hide();
    switch (pMsg->MsgId)
    {
    case WM_TOUCH:
    return;
    case WM_PID_STATE_CHANGED:
    break;
    case WM_KEY:
    break;
    case WM_PAINT:
    // Draw some Bitmaps and write texts on the screen with emWin-Functions GUI_DrawBitmap and GUI_DispStringInRectEx
    break;
    }
    }
    /************************************************************************************************************************************************************************/
    // Screen functions
    void ShowScreen1()
    {
    WM_DisableMemdev(WM_HBKWIN);
    GUI_Exec();
    m_Screen1= WM_CreateWindowAsChild(0,0,320,240, WM_HBKWIN, WM_CF_SHOW | WM_CF_MEMDEV, _cbScreen1, sizeof(WM_HWIN));
    m_Button1= BUTTON_CreateEx(0,0,320,37,m_Screen1,WM_CF_SHOW | WM_CF_MEMDEV,0,GUI_ID_BUTTON0);
    WM_SetCallback(m_Button1, _cButton1);
    WM_SendMessageNoPara(m_Button1, INIT_BUTTON);
    }
    void CloseScreen1()
    {
    if(m_Button1!=(GUI_HWIN)NULL)
    {
    BUTTON_Delete(m_Button1);
    m_Button1=(GUI_HWIN)NULL;
    }
    if(m_hHomeGNCScreenWin!=(GUI_HWIN)NULL)
    {
    WM_DetachWindow(m_Screen1);
    WM_DeleteWindow(m_Screen1);
    m_Screen1=(GUI_HWIN)NULL;
    }
    }
    /************************************************************************************************************************************************************************/
    // main
    int main(void)
    {
    GUI_Init();
    while(1)
    {
    ShowScreen1();
    GUI_Delay(1000);
    CloseScreen1();
    GUI_Delay(1000);
    }
    return(0);
    }

    Thanks
    Armin
  • Child-Window and Controls are deleted before creating, anyway appliaction hangs

    Hello Adrain,
    As you see in my Code above (on this side), i delete the screen(child window and Buttons) with "BUTTON_Delete" and "WM_DeleteWindow" and after that i create the screen again, i saw very often that the application hangs on "BUTTON_Delete" or "WM_DeleteWindow".
    My Appication is simplay as below:
    void main()
    {
    GUI_Init();
    while(1)
    {
    ShowScreen1();
    GUI_Delay(200);
    DeleteScrteen1()
    GUI_Delay(200);
    }
    }
    // For more details please see my code above(on this page)
    Best regards
    Armin
  • Hello Adrian,
    I had defined my handle variables af follow:
    static WM_HWIN m_Screen1=(GUI_HWIN)NULL;
    static BUTTON_Handle m_Button1=(GUI_HWIN)NULL;
    I had tried them with volatile too, as follow:
    volatile WM_HWIN m_Screen1=(GUI_HWIN)NULL;
    volatile BUTTON_Handle m_Button1=(GUI_HWIN)NULL;
    After several time of cretaing and deleting the the windows(in a display page), the application hangs in the function "BUTTON_Delete(m_Button1);" or "WM_DeleteWindow(m_Screen1);"
    BUTTON_Delete is defined as follow:
    #define BUTTON_Delete(hObj) WM_DeleteWindow (hObj)

    EmWin doesn't give any result back by these functions !!!, you can inform the developers to implement back Results for these functions please.
    Please see My Email from Aug.14.2013 on this page for more informations.
    Best regards
    Armin
  • Hello Armin,

    Please note that calling the function WM_DeleteWindow() with a handle to an existing window will always work. In order to determine possible errors, please define GUI_DEBUG_LEVEL with a value equal to or higher than GUI_DEBUG_LEVEL_LOG_WARNINGS.

    Best regards,
    Adrian
  • Hello Adrian,
    In my project the GUI_DEBUG_LEVEL is set to GUI_DEBUG_LEVEL_LOG_WARNINGS, with this value or GUI_DEBUG_LEVEL_LOG_ALL the application crashes anyway.
    The Application crash by "WM_DeleteWindow(m_Screen1);"
    When the WM_DeleteWindow(m_Screen1); works, the windows handle variable has the same value before and after call of this function !
    The Crash happens after about 10 times creating and deleting the childwindow.
    I don't use a GUI_Delay between creating,show and deleting the child-window.
    Please write me how long time as minimum must i set as delay between creating and deleting a child window?
    Shall i use GUI_Delay or a wait loop, please think on GUI_Exec(); in the main loop?
    Is it exists a way in emwin to find out why the crash in WM_DeleteWindow(...) happens?
    Best regards
    Armin
  • Hello Armin,

    Have you implemented the function GUI_X_Warn()? It is called to output warnings generated by emWin. For detailed information on how to handle debug output, please refer to the chapter "Configuration" in the emWin user manual. The reason for the problem is quite simple. You try to delete a window which is already deleted.

    Best regards,
    Adrian
  • Hello Adrian,
    Please see the documented code below, and read the qeustions.
    volatile GUI_ALLOC_DATATYPE m_GUI_ALLOC_DATATYPE;
    m_GUI_ALLOC_DATATYPE=GUI_ALLOC_GetNumUsedBytes();
    // Result: 984 Bytes are used
    // m_hButton1 is created and has the value 4
    if(m_hButton1!=(GUI_HWIN)NULL)
    {
    BUTTON_Delete(m_hButton1);
    // After ca. 5 times hangs the Applications in BUTTON_Delete-Function and doesn't come out, why?
    // After call of BUTTON_Delete-Function has m_hButton1 the value 4 , why doesn't set BUTTON_Delete-Function the value of m_hButton1 of NULL ?
    m_hButton1=(GUI_HWIN)NULL; // Manuelly setting of m_hButton1 to NULL
    }
    m_GUI_ALLOC_DATATYPE=GUI_ALLOC_GetNumUsedBytes();
    // 852 Bytes are used
    Best regards
    Armin
  • Hello Armin,

    Could you please answer the question from my previous post?

    Have you implemented the function GUI_X_Warn()?

    The value contained by the window handle is not changed by the function BUTTON_Delete(), because it is set by the ...Create()-functions. Regular calls of a ...Delete()-function without a prior call of a ...Create()-function are not recommended.

    Best regards,
    Adrian
  • Hello Adrian,
    I didn't try the function GUI_X_Warn() because of missing time, if you have an example you can send me it please, i see to take informations in internet too.
    As i wrote you the windows handle were set(windows were created) befor of calling of WM_DeleteWindow(...), it works well, but after several times of creating and deleting of them, the application hangs in the function WM_DeleteWindow(...)
    Best regards
    Armin