From b01f603a4cb7cfb8f80415add72516c1a4dce2fc Mon Sep 17 00:00:00 2001 From: gambas Date: Fri, 14 May 2021 01:19:29 +0200 Subject: [PATCH] Display the warning about calling the event loop during a keyboard event once. [GB.GTK] * NEW: Display the warning about calling the event loop during a keyboard event once. [GB.GTK3] * NEW: Display the warning about calling the event loop during a keyboard event once. [GB.QT4] * NEW: Display the warning about calling the event loop during a keyboard event once. [GB.QT5] * NEW: Display the warning about calling the event loop during a keyboard event once. --- gb.gtk3/src/main.cpp | 8 +++++++- gb.qt4/src/main.cpp | 10 +++++++++- gb.qt5/src/main.cpp | 10 +++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gb.gtk3/src/main.cpp b/gb.gtk3/src/main.cpp index 6e02d16d1..8866eda5d 100644 --- a/gb.gtk3/src/main.cpp +++ b/gb.gtk3/src/main.cpp @@ -584,6 +584,8 @@ static int hook_loop() static void hook_wait(int duration) { + static bool _warning = FALSE; + if (gDrawingArea::inAnyDrawEvent()) { GB.Error("Wait is forbidden during a repaint event"); @@ -592,7 +594,11 @@ static void hook_wait(int duration) if (duration && gKey::isValid()) { - fprintf(stderr, "gb.gtk3: warning: calling the event loop during a keyboard event handler is ignored\n"); + if (!_warning) + { + fprintf(stderr, "gb.gtk3: warning: calling the event loop during a keyboard event handler is ignored\n"); + _warning = TRUE; + } return; } diff --git a/gb.qt4/src/main.cpp b/gb.qt4/src/main.cpp index 8474bfb05..536ea7762 100644 --- a/gb.qt4/src/main.cpp +++ b/gb.qt4/src/main.cpp @@ -1038,6 +1038,8 @@ static void hook_loop() static void hook_wait(int duration) { + static bool _warning = FALSE; + if (MyDrawingArea::inAnyDrawEvent()) { GB.Error("Wait is forbidden during a repaint event"); @@ -1049,7 +1051,13 @@ static void hook_wait(int duration) if (duration > 0) { if (CKEY_is_valid()) - fprintf(stderr, QT_NAME ": warning: calling the event loop during a keyboard event handler is ignored\n"); + { + if (!_warning) + { + fprintf(stderr, QT_NAME ": warning: calling the event loop during a keyboard event handler is ignored\n"); + _warning = TRUE; + } + } else qApp->processEvents(QEventLoop::AllEvents, duration); } diff --git a/gb.qt5/src/main.cpp b/gb.qt5/src/main.cpp index ef8632a19..055a5bc7f 100644 --- a/gb.qt5/src/main.cpp +++ b/gb.qt5/src/main.cpp @@ -802,6 +802,8 @@ static void hook_loop() static void hook_wait(int duration) { + static bool _warning = FALSE; + if (MyDrawingArea::inAnyDrawEvent()) { GB.Error("Wait is forbidden during a repaint event"); @@ -813,7 +815,13 @@ static void hook_wait(int duration) if (duration > 0) { if (CKEY_is_valid()) - fprintf(stderr, QT_NAME ": warning: calling the event loop during a keyboard event handler is ignored\n"); + { + if (!_warning) + { + fprintf(stderr, QT_NAME ": warning: calling the event loop during a keyboard event handler is ignored\n"); + _warning = TRUE; + } + } else qApp->processEvents(QEventLoop::AllEvents, duration); }