Hello all,

I'm writing a Haskell binding to Imlib 2, and noticed some strange
behaviour in my function which manages the allocation/deallocation of
contexts. The following examples in C demonstrate the strange
behaviour I'm seeing.

The following program prints 0 1 0 2 2, and not 0 1 0 2 1 as I'd expect it to:

#include <Imlib2.h>
#include <stdio.h>

int main (void) {
    Imlib_Context c1;

    printf("%i ", imlib_context_get_colormap());
    imlib_context_set_colormap(1);
    printf("%i ", imlib_context_get_colormap());

    c1 = imlib_context_new();
    imlib_context_push(c1);

    printf("%i ", imlib_context_get_colormap());
    imlib_context_set_colormap(2);
    printf("%i ", imlib_context_get_colormap());

    imlib_context_pop();
    imlib_context_free(c1);

    printf("%i\n", imlib_context_get_colormap());

    return 0;
}

Somehow, the colormap set in the pushed context doesn't get reset when
that context is popped.

Now consider the following program:

#include <Imlib2.h>
#include <stdio.h>

int main (void) {
    Imlib_Context c1, c2;

    // Create and then immediately throw away a context.
    c2 = imlib_context_new();
    imlib_context_push(c2);
    imlib_context_pop();
    imlib_context_free(c2);

    // The rest is the same.
    printf("%i ", imlib_context_get_colormap());
    imlib_context_set_colormap(1);
    printf("%i ", imlib_context_get_colormap());

    c1 = imlib_context_new();
    imlib_context_push(c1);

    printf("%i ", imlib_context_get_colormap());
    imlib_context_set_colormap(2);
    printf("%i ", imlib_context_get_colormap());

    imlib_context_pop();
    imlib_context_free(c1);

    printf("%i\n", imlib_context_get_colormap());

    return 0;
}

One might expect that this program would print exactly the same thing
as the first, given that the only difference is that it creates,
pushes, pops and then throws away a context at the start of the
program. However, it actually behaves more in line with how I'd
expected the first program to behave. That is, it prints 0 1 0 2 1.

Doing some more experiments, it appears that the create/push/pop/free
of that new context seems to have turned the result of
imlib_context_get() from NULL into something non-null, which would
perhaps help to explain why it's happening.

Is this expected behaviour? I noticed that the context creation
functions aren't in the HTML documentation, are they meant to be used
directly like this? I would certainly prefer it if the initial context
set up by the library behaved like all the others right away.

 - Cale

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to