Re: wxEuphoria image loading problems

new topic     » goto parent     » topic index » view thread      » older message » newer message

D. Newhall wrote:
> 
> When an event occurs (in this code a mouse click (which BTW desperately needs
> documentation in the wxEuphoria docs)) the handling routine calls open_image
> which destroys the last image object and creates the next one. After a while
> a message box will pop up saying it can't open the file for the next one. The
> image file read obviously exists since it was able to open it before so the
> problem is either a file locking issue or I'm doing stuff incorrectly.
> 

Yes, it's a file locking issue.  You're opening the file, but never 
closing it, eventually exhausting Euphoria's limit on number of open
files.  Try this:
procedure open_image(sequence filename)
    integer x
    if Current_image > 0 then
        delete_instance(Current_image)
    end if

    --filename = DATA_DIR & Directory & "/" & filename & ".bmp"
    filename = DATA_DIR & filename & ".bmp"

    x = open(filename, "r")
    if x = -1 then
        error("File \"" & filename & "\"could not be opened.")
    else
    	close(x)
    end if

    Current_image = create(wxBitmap,
      {BM_FROM_FILE, filename, wxBITMAP_TYPE_BMP})

end procedure  -- open_scene_image



Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu