I'm developing an image processing application where, one of the routines takes more than 5 seconds to process. To make this process more professional, I want to display a window, showing a "please wait" message while that routine takes it's time.
The problem is that, although the code executes sequentially, like it should, the popups only appear after the 5 second-routine runs, and not before like they should.
The logic is:
- showacceptdialog(saying image file loaded ok, requires pressing the
ok button)
- call the image processing method
- showmessagewindow(show popup panel, no input required)
- process_image()
- showmessagewindow(hide popup panel)
This image processing method translates to the following code (heavily simplified):
func carregar_imagem(_foto):
Foto = _foto
# This calls the method to show the "please wait" popup panel
apresentar_mensagem_espera(true)
if Foto.path_ficheiro.length() > 0:
var pal = palette_cores.new()
# The next method takes between 5 to 6 seconds to run
var cores = pal.calcular(Foto.path_ficheiro)
# Hides the "please wait" popup panel
apresentar_mensagem_espera(false)
With this code, the popup never appears, although it is executed in the right sequence, because Godot only updates the GUI after the routine completes.
I've tried several yields (idleframe, physicsframe, completed, custom signals, splitting the method in two, having a signal call the second part) between apresentar_mensagem_espera(true)
and pal.calcular
but nothing makes Godot show the popup before running the pal.calcular
method.
Does anyone knows a way to make it stop, update the GUI and then process the rest? Having the program "freeze" for 5 seconds with no feedback is bad.