LISTVIEW_GetSelUnsorted crashes if no Row in the ListView

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

  • 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 Source Code

    1. static const GUI_WIDGET_CREATE_INFO _aListJob[] = {
    2. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 800, 480, 0, 0x0, 0 },
    3. { LISTVIEW_CreateIndirect, "Listview", GUI_ID_LISTVIEW0, 8, 85, 787, 300, 0, 0x0, 0 },
    4. };
    5. static void _cbDialogListJob(WM_MESSAGE * pMsg) {
    6. WM_HWIN hItem;
    7. switch (pMsg->MsgId) {
    8. case WM_INIT_DIALOG:
    9. hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTVIEW0);
    10. LISTVIEW_AddColumn(hItem, 2, "Nom", GUI_TA_LEFT | GUI_TA_TOP);
    11. LISTVIEW_AddColumn(hItem, 220, "Nom", GUI_TA_LEFT | GUI_TA_TOP);
    12. LISTVIEW_AddColumn(hItem, 395, "Description", GUI_TA_LEFT | GUI_TA_TOP);
    13. LISTVIEW_AddColumn(hItem, 155, "Date", GUI_TA_LEFT | GUI_TA_TOP);
    14. LISTVIEW_SetCompareFunc(hItem, 0, LISTVIEW_CompareDec);
    15. LISTVIEW_SetCompareFunc(hItem, 1, LISTVIEW_CompareText);
    16. LISTVIEW_SetCompareFunc(hItem, 3, LISTVIEW_CompareText);
    17. LISTVIEW_SetSort(hItem,1,1);
    18. break;
    19. default:
    20. WM_DefaultProc(pMsg);
    21. break;
    22. }
    23. }
    24. void MainTask(void) {
    25. WM_HWIN v_hwin;
    26. int sel;
    27. static const char * _aTable_1[][4] = {
    28. {"1", "A", "Info 1", "07/07/2017\n14:33"},
    29. {"3", "E", "Info 2", "06/08/2017\n15:33" },
    30. {"5", "B", "Info 3", "06/10/2017\n14:40" },
    31. { "15","Z", "Info 4", "06/07/2016\n14:40" },
    32. { "18","I", "Info 5", "24/07/2017\n14:58" },
    33. { "20","A", "Info 6", "31/12/2017\n14:12" },
    34. { "21","C", "Info 7", "06/07/2017\n23:33" },
    35. { "32","F", "Info 8", "06/07/2013\n14:33" },
    36. };
    37. GUI_Init(); // Initialize the GUI
    38. WM_SetBkWindowColor(GUI_WHITE); // Set a default background color
    39. GUI_Clear();
    40. v_hwin = GUI_CreateDialogBox(_aListJob, GUI_COUNTOF(_aListJob), _cbDialogListJob, WM_HBKWIN, 0, 0);
    41. GUI_Delay(1000);
    42. sel = LISTVIEW_GetSelUnsorted(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0));
    43. LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1);
    44. GUI_Delay(1000);
    45. LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+4);
    46. GUI_Delay(1000);
    47. LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+8);
    48. GUI_Delay(1000);
    49. LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+12);
    50. GUI_Delay(1000);
    51. LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+16);
    52. GUI_Delay(1000);
    53. LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+20);
    54. GUI_Delay(1000);
    55. LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+24);
    56. GUI_Delay(1000);
    57. do
    58. {
    59. GUI_Delay(1000);
    60. }while(1);
    61. }
    Display All