GUI_alloc erro

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

  • GUI_alloc erro

    Hi,
    I get the following error when I try to delete the graph widget using WM_DeleteWindow "gui_alloc.c: block to be deleted is already locked in free()".

    Why is that so?

    Thanks,
  • Hi Adrian,
    No the graph window hasn't been deleted.
    The graph has been created as follows:
    GUI_data.Graph_win = GRAPH_CreateEx(WINDOW_POS_X, (WINDOW_POS_Y+35), WINDOW_SIZE_X, 378, WM_HBKWIN, WM_CF_SHOW| WM_CF_CONST_OUTLINE, 0, 0);

    After the processing, I am using WM_DeleteWindow to delete the instance as follows:


    if (GUI_data.Graph_win != 0)
    {
    WM_DeleteWindow(GUI_data.Graph_win);
    GUI_data.Graph_win = 0;
    }


    I tried using GraphDelete functions but the background window still shows the graph.

    Thanks
  • Hi,
    No, it only gives me an error when I attach the data using the following line of code
    GRAPH_AttachData(GUI_data.Graph_win, GUI_data.Graph_data1);

    Thanks

    The post was edited 1 time, last by Ana ().

  • Hi,
    I have used the following code to create the data for the graph

    I16 Transducer_data1[40];
    GRAPH_DATA_Handle Graph_data1;
    I16 Graph_pixel_data1[720];

    static void graph_data_computation(U8 new_old)
    {
    unsigned int i, j, k;
    float diff1, diff2;

    GUI_data.Transducer_data1[0] = 10;
    GUI_data.Transducer_data1[1] = 11;
    GUI_data.Transducer_data1[2] = 12;
    if (new_old == 1)
    {
    GRAPH_DATA_YT_Clear(GUI_data.Graph_data1);
    for(i=0; i<65530;i++);
    GUI_data.Transducer_data1[0] = 20;
    GUI_data.Transducer_data1[1] = 1;
    GUI_data.Transducer_data1[2] = 27;
    }
    GUI_data.Transducer_data1[3] = 13;
    GUI_data.Transducer_data1[4] = 14;
    GUI_data.Transducer_data1[5] = 15;
    GUI_data.Transducer_data1[6] = 25;
    GUI_data.Transducer_data1[7] = 26;
    GUI_data.Transducer_data1[8] = 27;
    GUI_data.Transducer_data1[9] = 28;
    GUI_data.Transducer_data1[10] = 29;
    GUI_data.Transducer_data1[11] = 30;
    GUI_data.Transducer_data1[12] = 5;
    GUI_data.Transducer_data1[13] = 6;
    GUI_data.Transducer_data1[14] = 7;
    GUI_data.Transducer_data1[15] = 8;
    GUI_data.Transducer_data1[16] = 9;
    GUI_data.Transducer_data1[17] = 10;
    GUI_data.Transducer_data1[18] = 20;
    GUI_data.Transducer_data1[19] = 21;
    GUI_data.Transducer_data1[20] = 22;
    GUI_data.Transducer_data1[21] = 23;
    GUI_data.Transducer_data1[22] = 24;
    GUI_data.Transducer_data1[23] = 25;
    GUI_data.Transducer_data1[24] = 30;
    GUI_data.Transducer_data1[25] = 31;
    GUI_data.Transducer_data1[26] = 32;
    GUI_data.Transducer_data1[27] = 33;
    GUI_data.Transducer_data1[28] = 34;
    GUI_data.Transducer_data1[29] = 35;
    GUI_data.Transducer_data1[30] = 36;
    GUI_data.Transducer_data1[31] = 37;
    GUI_data.Transducer_data1[32] = 38;
    GUI_data.Transducer_data1[33] = 39;
    GUI_data.Transducer_data1[34] = 16;
    GUI_data.Transducer_data1[35] = 17;
    GUI_data.Transducer_data1[36] = 18;
    GUI_data.Transducer_data1[37] = 19;
    GUI_data.Transducer_data1[38] = 20;
    GUI_data.Transducer_data1[39] = 21;
    GUI_data.Transducer_data1[40] = 22;

    //Interpolation function to create 720 points
    for (i=0,k=0; i<720; k++)
    {
    if (k<40)
    {
    if (GUI_data.Transducer_data1[k+1] > GUI_data.Transducer_data1[k])
    {
    diff1 = ((GUI_data.Transducer_data1[k+1] - GUI_data.Transducer_data1[k])/18 ) ;
    }
    else
    {
    diff1 = ((GUI_data.Transducer_data1[k] - GUI_data.Transducer_data1[k+1])/18 ) ;
    }
    }
    for(j=0; j<18; j++,i++)
    {
    GUI_data.Graph_pixel_data1 = (GUI_data.Transducer_data1[k] + (j*diff1))*10;
    }
    }

    GUI_data.Graph_data1 = GRAPH_DATA_YT_Create(GUI_YELLOW, 720, GUI_data.Graph_pixel_data1, 720);
    GRAPH_AttachData(GUI_data.Graph_win, GUI_data.Graph_data1);

    GRAPH_DATA_YT_SetAlign(GUI_data.Graph_data1, GRAPH_ALIGN_LEFT);
    return;
    }

    What am I missing here?

    Thanks
  • Hi,
    I have checked and the GRAPH_DATA_YT_Create() returns a non-zero value. So the data object is being created successfully.
    Please help me with this issue. I have read the documentation and am unable to find any fault.

    When is the following error generated ""gui_alloc.c: block to be deleted is already locked in free()"

    Thanks
  • Hello,

    Unfortunately I am not able to reproduce the problem. You wrote in one of your previous posts:
    I tried using GraphDelete functions but the background window still shows the graph.
    Could you please try calling the function WM_SetDesktopColor() right after GUI_Init()? The reason for a deleted window to still be shown is that the window "below" does not repaint itself. This is caused by the fact that the desktop window does not handle paint events at all unless a dekstop color or a custom callback function is set.

    Best regards,
    Adrian
  • Hi,
    I have tried calling the WM_SetDesktopColor. immediately after GUI_Init(). I have attached a screenshot of the graph screen and the screen after I delete the the graph using GRAPH_DATA_YT_Delete(GUI_data.Graph_data1); and after creating listbox screen.
    I am also calling WM_SetDesktopColor(GUI_BLACK); after deleting the graph window.

    Thanks,
  • Hi,
    Following is the code I have used to create the graph window.
    GUI_data.Graph_win = GRAPH_CreateEx(WINDOW_POS_X, (WINDOW_POS_Y+35), WINDOW_SIZE_X, 378, WM_HBKWIN, WM_CF_SHOW| WM_CF_CONST_OUTLINE, 0, 0);

    WIDGET_SetEffect(GUI_data.Graph_win, &WIDGET_Effect_None);
    GRAPH_SetBorder(GUI_data.Graph_win, 60, 10, 40, 40);
    GRAPH_SetColor(GUI_data.Graph_win, GUI_BLACK, GRAPH_CI_BK);
    GRAPH_SetColor(GUI_data.Graph_win, GUI_BLACK, GRAPH_CI_BORDER);
    GRAPH_SetColor(GUI_data.Graph_win, GUI_WHITE, GRAPH_CI_FRAME);
    GRAPH_SetColor(GUI_data.Graph_win, GUI_WHITE, GRAPH_CI_GRID);

    GRAPH_SetGridDistX (GUI_data.Graph_win, ((WINDOW_SIZE_X - 40 - 40)/6));//41);
    GRAPH_SetGridDistY(GUI_data.Graph_win, ((380 - 5 - 40)/8 ));//119);
    GRAPH_SetGridFixedX (GUI_data.Graph_win, 1);
    GRAPH_SetGridVis(GUI_data.Graph_win, 1);

    GRAPH_SetAutoScrollbar(GUI_data.Graph_win, GUI_COORD_X|GUI_COORD_Y,0);


    GUI_data.Graph_scale1 = GRAPH_SCALE_Create(340, GUI_TA_RIGHT, GRAPH_SCALE_CF_HORIZONTAL, 10);//118 );
    GRAPH_SCALE_SetFont(GUI_data.Graph_scale1, &GUI_FontArial_Unicode_MS26);
    GRAPH_SCALE_SetTextColor(GUI_data.Graph_scale1, GUI_YELLOW);
    GRAPH_SCALE_SetTickDist(GUI_data.Graph_scale1, 100);
    GRAPH_SCALE_SetFactor(GUI_data.Graph_scale1, 0.1);
    GRAPH_SCALE_SetNumDecs(GUI_data.Graph_scale1, 0);

    GRAPH_AttachScale(GUI_data.Graph_win, GUI_data.Graph_scale1);

    GUI_data.Lift_completed = 0;
    graph_data_computation(0);

    GRAPH_SetUserDraw(GUI_data.Graph_win, _UserDraw);
    WM_SetCallback(WM_HBKWIN, callback_graph_screen);
    WM_SetFocus(WM_HBKWIN);

    I have checked and after the graph window, only the back window remains.

    Need urgent input.

    Thanks,

    The post was edited 1 time, last by Ana ().

  • HI,
    I have tried with both using custom callback for the background window as well as just using WM_SetDesktop color(GUI_BLACK).
    Summary of the scenarios:
    1) Using WM_DeleteWindow function.
    Following error message is seen, but graph window is properly deleted and other functionality works fine.
    Following is the code:
    if (GUI_data.Graph_win != 0)
    {
    WM_DeleteWindow(GUI_data.Graph_win);
    WM_SetCallback(WM_HBKWIN, callback_backwindow);
    WM_SetFocus(WM_HBKWIN);
    WM_SetDesktopColor(GUI_BLACK);
    WM_Paint(WM_HBKWIN);
    GUI_data.Graph_win = 0;
    }

    2) Using "GRAPH_DATA_YT_Delete" function
    No error is given but the base window is not redrawn properly and other functionality doesn't work properly.
    Following is the code:
    if (GUI_data.Graph_win != 0)
    {
    GRAPH_DATA_YT_Delete(GUI_data.Graph_data1);
    WM_SetCallback(WM_HBKWIN, callback_backwindow);
    WM_SetFocus(WM_HBKWIN);
    WM_SetDesktopColor(GUI_BLACK);
    WM_Paint(WM_HBKWIN);
    GUI_data.Graph_win = 0;
    }

    Following is the callback function code:
    static void callback_backwindow(WM_MESSAGE * pMsg)
    {
    switch (pMsg->MsgId)
    {
    case WM_PAINT:
    if((pMsg->hWin) == WM_HBKWIN)
    {
    GUI_Clear();
    //draw the background borders and lines
    Background_draw();
    }
    break;

    default:
    WM_DefaultProc(pMsg);
    break;
    }
    return;
    }

    Thanks
  • Hello,

    It should be sufficient to set the callback function for the background window once. Also setting the input focus to the background window should not be necessary. The background window does not include any interactions with input devices. Setting the desktop color is not required in case there is a callback function which already responds to the WM_PAINT message.

    Calling the function WM_Paint() is not required in most cases. Windows are automatically redrawn once the Window Manager is executed.

    Best regards,
    Adrian