Tuesday, January 23rd 2018, 8:38am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

1

Thursday, November 13th 2014, 6:27am

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,

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

2

Thursday, November 13th 2014, 9:14am

Hello,

Is there a possibility you already deleted the window?

Best regards,
Adrian

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

3

Thursday, November 13th 2014, 11:14am

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

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

4

Friday, November 14th 2014, 9:49am

Hello,

Does this also happen if you just create and immediately delete the GRAPH widget?

Best regards,
Adrian

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

5

Friday, November 14th 2014, 10:44am

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

This post has been edited 1 times, last edit by "Ana" (Nov 14th 2014, 11:04am)


SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

6

Monday, November 17th 2014, 9:30am

Hello,

Did you successfully create the data object you intend to attach to the GRAPH widget? For details please refer to the chapter "Widgets" in the emWin user manual.

Best regards,
Adrian

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

7

Monday, November 17th 2014, 1:17pm

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

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

8

Tuesday, November 18th 2014, 3:34pm

Hello,

Did you successfully create the data object you intend to attach to the GRAPH widget? The data object was successfully created in case the GRAPH_DATA_YT_Create() returns a value other than 0.

Best regards,
Adrian

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

9

Wednesday, November 19th 2014, 6:35am

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

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

10

Wednesday, November 19th 2014, 10:18am

Hello,

Unfortunately I am not able to reproduce the problem. You wrote in one of your previous posts:

Quoted

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

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

11

Wednesday, November 19th 2014, 10:55am

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,

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

12

Thursday, November 20th 2014, 9:30am

Hello,

There must be a window below the GRAPH widget which is not redrawing itself. Please make sure that all windows are drawn properly.

Best regards,
Adrian

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

13

Thursday, November 20th 2014, 9:52am

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,

This post has been edited 1 times, last edit by "Ana" (Nov 20th 2014, 9:53am)


SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

14

Thursday, November 20th 2014, 4:19pm

Hello,

Is the background window drawn? Did you use the function WM_SetDesktopColor or did you implement a custom callback function for the background window which properly processes WM_PAINT messages?

Best regards,
Adrian

Ana

Beginner

Date of registration: Feb 13th 2014

Posts: 27

15

Friday, November 21st 2014, 5:52am

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

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

16

Tuesday, November 25th 2014, 4:23pm

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

Similar threads