Home Forums General Programming AlertWindow : how to change message and close window?

This topic contains 5 replies, has 2 voices, and was last updated by Carl Licroy Carl Licroy 2 years, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18507
    Carl Licroy
    Carl Licroy
    Participant

    Hi, this is my code for requesting patch names from Prophet08:

    
    -- Create a coroutine in order to wait getting patch name before insertion in table
    GetPatchName = coroutine.create(function()
         for patch_number = 0, 127  do 		
              Receive_request_program_dump(0,patch_number)
              coroutine.yield(x)
              console ("Inserting patch name in table")
              Bank1PatchesTable[patch_number] = PatchName
         end
    end)
    coroutine.resume(GetPatchName)
    

    Everything works fine, but I want to create a message to inform the user about the dump progress and tried this :

    
    DumpProgress = AlertWindow.showMessageBoxAsync(AlertWindow.InfoIcon, "Patch dump", "Patch 0 of 256", "Cancel")
    
    GetPatchName = coroutine.create(function()
         for patch_number = 0, 127  do 		
              Receive_request_program_dump(0,patch_number)
              coroutine.yield(x)
              console ("Inserting patch name in table")
              Bank1PatchesTable[patch_number] = PatchName
              RealPatchNumber = patch_number + 1
              DumpProgress:setMessage("Patch "..RealPatchNumber.." of 256")
         end
         DumpProgress:~AlertWindow()
    end)
    coroutine.resume(GetPatchName)

    SetMessage doesn’t work to change AlertWindow message and compilation failed with the command “~AlertWindow()”. I don’t know how to achieve it… Any help would be very appreciated.

    #18512
    atom
    atom
    Moderator

    I’ll have a look why AlertWindow is not working (i know it was when i was writing it, but maybe something changed in JUCE and broke it)

    One thing is 100% you can’t call ~AlertWindow(), this is the destructor of that class, all the lifetime of those classes is controlled in C++ or by the Lua’s garbage collector, don’t do that.

    Also this won’t really do what you want, this is all done on one thread (the main GUI thread) so you won’t see any updates in the AlertWindow cause Lua will be blocking it with whatever you are doing, you’d need a new thread or the specialized class in JUCE called (ThreadWithProgressWindow) to do this stuff. It’s not implemented because threading lua and Ctrlr might cause loads of issues.

    I’ll try to figure this out so we can make progress indicators for lengthy operations (this sort of stuff is partially implemented in the new program manager so hopefuly it won’t be needed, but i’ll think about it)

    • This reply was modified 2 years, 12 months ago by atom atom.
    • This reply was modified 2 years, 12 months ago by atom atom.
    • This reply was modified 2 years, 12 months ago by atom atom.
    #18534
    Carl Licroy
    Carl Licroy
    Participant

    Thanks Atom, maybe a solution would be to open an AlertWindow for each patch loaded and to close it each time a new patch is loaded. I understand now why I can’t use ~AlertWindow(), is there an other way to programmaticaly close the window (without waiting for user to click “ok”)?

    #18537
    atom
    atom
    Moderator

    Well in theory calling exitModalState on the AlertWindow object should make it exit (since AlertWindow is a Component object). But i haven’t tested it yet, i’ll get back to you on that.

    #18538
    atom
    atom
    Moderator

    I also noticed you are using coroutines, theese are run on different thread. Without locking using different threads will cause unexpected results and crashes all over the place. Please remember that.

    #18873
    Carl Licroy
    Carl Licroy
    Participant

    Yes I use coroutines to stop program dump loop until midi message is received and treated by other function. It works well so far.

    I tried to use exitModalState but it doesn’t work. But I finally found a better solution by displaying current loaded patch name and number in the panel lcd display.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Comments are closed.