Knob Widget causing memory corruption

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

    • Knob Widget causing memory corruption


      I am using Emwin simulation project on windows. I have a window2 on which am using a knob widget and i navigate to this window2 from other window1.
      I have a back button among other buttons and widgets on the window2.

      After navigation to this window2 I press back button to go to previous window1. I have used WM_Delete function to delete the current window and then called createwindow of window1 to create window1.

      My application crashes when delete window2 is called and then create window1 is called. i observed that some local variables become are corrupt in the callback function.
      When i remove the knob widget from the window2 the application does not crash when same navigation process is performed. so i believe the knob widget is causing the memory corruption

      I have around 21 widgets on the window2 including knob widget. I changed the order of the knob widget from top to down in widget table and the issue is not observed.
      Capture.PNG is the widget order in table for which the issue comes and Capture1.PNG is the widget order in table for which the issue is not observed,
      In case of Capture.PNG the delete window is called on button which is created below and after which application crashes
      If the knob widget is moved below all the buttons as in Capture2.PNG the issue is not observed.

      The knob widget is 235x235 and used memdev for this
      memory is #define GUI_NUMBYTES 0x500000 which is very high.

      Initialised the knob as below

      // Draw knob as per set point.
      hKnob = GetWindowItem(pMessage->hWin, GUI_ID_KNOB_0);
      hMem = MEMDEV_CreateFixed32(0 0, 235, 235);
      DrawBitmap(&bmdial, 0, 0);

      KNOB_SetMemDevice(hKnob, hMem);

      Am able to see the knob as per initialization on window2
      I have deleted the hMem on window WM_DELETE event using GUI_MEMDEV_Delete

      I have observed one behavior only changing the order of one button and keeping knob at the top as in Capture.PNG also resolves the problem
      Should the order of the Widget ids defined match the order of widgets in the widget table?. This is not the case in my code

      Does anyone have any inputs on this?

      • Capture.PNG

        14.17 kB, 261×340, viewed 91 times
      • Capture1.PNG

        14.06 kB, 256×334, viewed 89 times

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