Tuesday, May 22nd 2018, 12:32am UTC+2

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.

YPO53

Beginner

Date of registration: Oct 4th 2016

Posts: 28

1

Tuesday, October 31st 2017, 4:43pm

LISTVIEW_GetSelUnsorted crashes if no Row in the ListView

Hello.

I think there is a bug in the LISTVIEW_GetSelUnsorted function when this function is called while there is no Row in the list view.
I am using Emwin 5.32

If I call this line :
sel = LISTVIEW_GetSelUnsorted(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0));
before adding a row, I got a crash in _LISTVIEW_SetSort

BUT if I call this line after a Adding a row All is OK.

Note, that if I don't call LISTVIEW_SetSort(hItem,1,1);
It will work ...




here is my code :

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
static const GUI_WIDGET_CREATE_INFO _aListJob[] = {
    { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 800, 480, 0, 0x0, 0 },
    { LISTVIEW_CreateIndirect, "Listview", GUI_ID_LISTVIEW0, 8, 85, 787, 300, 0, 0x0, 0 },
};


static void _cbDialogListJob(WM_MESSAGE * pMsg) {
    WM_HWIN hItem;
    switch (pMsg->MsgId) {
        case WM_INIT_DIALOG:
            hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTVIEW0);
            LISTVIEW_AddColumn(hItem, 2, "Nom", GUI_TA_LEFT | GUI_TA_TOP);
            LISTVIEW_AddColumn(hItem, 220, "Nom", GUI_TA_LEFT | GUI_TA_TOP);
            LISTVIEW_AddColumn(hItem, 395, "Description", GUI_TA_LEFT | GUI_TA_TOP);
            LISTVIEW_AddColumn(hItem, 155, "Date", GUI_TA_LEFT | GUI_TA_TOP);
            LISTVIEW_SetCompareFunc(hItem, 0, LISTVIEW_CompareDec);
            LISTVIEW_SetCompareFunc(hItem, 1, LISTVIEW_CompareText);
            LISTVIEW_SetCompareFunc(hItem, 3, LISTVIEW_CompareText);
            LISTVIEW_SetSort(hItem,1,1);
        break;
        default:
            WM_DefaultProc(pMsg);
        break;
    }
}

void MainTask(void) {
    WM_HWIN v_hwin;
    int sel;
    static const char * _aTable_1[][4] = {
        {"1", "A", "Info 1", "07/07/2017\n14:33"},
        {"3", "E", "Info 2", "06/08/2017\n15:33" },
        {"5", "B", "Info 3", "06/10/2017\n14:40" },
        { "15","Z", "Info 4", "06/07/2016\n14:40" },
        { "18","I", "Info 5", "24/07/2017\n14:58" },
        { "20","A", "Info 6", "31/12/2017\n14:12" },
        { "21","C", "Info 7", "06/07/2017\n23:33" },
        { "32","F", "Info 8", "06/07/2013\n14:33" },
    };

    GUI_Init(); // Initialize the GUI
    WM_SetBkWindowColor(GUI_WHITE); // Set a default background color
    GUI_Clear(); 
    
    v_hwin = GUI_CreateDialogBox(_aListJob, GUI_COUNTOF(_aListJob), _cbDialogListJob, WM_HBKWIN, 0, 0);
    GUI_Delay(1000);

    sel = LISTVIEW_GetSelUnsorted(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0));

    LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1);
    GUI_Delay(1000);
    LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+4);
    GUI_Delay(1000);
    LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+8);
    GUI_Delay(1000);
    LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+12);
    GUI_Delay(1000);
    LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+16);
    GUI_Delay(1000);
    LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+20);
    GUI_Delay(1000);
    LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+24);
    GUI_Delay(1000);
    

    do
    {
        GUI_Delay(1000);
    }while(1);

}

Similar threads