lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.03k stars 189 forks source link

Please add example how to poll for events with SDL2 #459

Closed oschettler closed 5 months ago

oschettler commented 7 months ago

I don't get this to work. With the standard setup, if I include this code in loop() (which is run in a separate thread), the app crashes in SDL_PollEvent()

  SDL_Event event;
  while (SDL_PollEvent(&event)) {
    switch (event.type) {
      case SDL_QUIT:
        running = 0;
        break;
  }}

This ist the output:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007ff80e7e90b6 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff80e2de231 objc_exception_throw + 48
    2   AppKit                              0x00007ff81266dcc9 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4241
    3   libSDL2-2.0.0.dylib                 0x000000010568858e Cocoa_PumpEventsUntilDate + 84
    4   libSDL2-2.0.0.dylib                 0x0000000105688760 Cocoa_PumpEvents + 59
    5   libSDL2-2.0.0.dylib                 0x00000001055e86ef SDL_PumpEventsInternal + 55
    6   libSDL2-2.0.0.dylib                 0x00000001055e87f5 SDL_WaitEventTimeout_REAL + 80
    7   passwordvault_0.1.1                 0x00000001023b4283 _Z4loopv + 51
    8   passwordvault_0.1.1                 0x00000001023b4c95 _Z9user_funcPb + 21
    9   libSDL2-2.0.0.dylib                 0x000000010562b048 SDL_RunThread + 44
    10  libSDL2-2.0.0.dylib                 0x000000010569c2c1 RunThread + 9
    11  libsystem_pthread.dylib             0x00007ff80e69b202 _pthread_start + 99
    12  libsystem_pthread.dylib             0x00007ff80e696bab thread_start + 15
)
libc++abi: terminating due to uncaught exception of type NSException
Abort trap: 6

My machine is a Mac with Sonoma.

lovyan03 commented 6 months ago

I do not understand what you are trying to say. Please explain a little more.

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 5 months ago

This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.