Skip to content

Assertion errors in “newPixbufFromFile” if an error occurred. #75

@lscrd

Description

@lscrd

If the file we try to load in a Pixbuf doesn’t contain an image, an error is returned by Gtk but it is ignored in newPixbufFromFile. Thus, we are in an inconsistent state and the next instructions in newPixbufFromFile cause assertion errors (which can be seen if we launch the program from a terminal).

To avoid this, it would be necessary to exit prematurely from newPixbufFromFile if an error occurred. For instance, the proc could return nil instead of the expected Pixbuf. This is not perfect as we have no way to retrieve the error code in order to understand why the loading failed.

A better solution could be to raise an exception whose value contains the error code i.e. a glib.Error (GError).

For now, I have changed my code to check the type of the file I try to load, before actually loading it. But if an error occurs for some other reason, I’m still in trouble.

Note that the same problem exists for newPixbufAnimationFromFile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions