I still not have understood why my code doesn't work. I attached to the mail an 
other source file which produce this result when I execute it :
    - Action 1 or 3 :   "Access violation reading location" in 
"pthread_mutex_lock.c" on line
                                if(mx->kind == PTHREAD_MUTEX_NORMAL)
    - Action 2 or 4 : no problem

The only difference between Actions 1/3 and Actions 2/4 is that Actions 2 and 4 
do not call the AG_ObjectFreeChildren function. If somebody can say me if he 
has the same error with this code it could really help me.

Thanks for your time,
JC




________________________________
De : Julien Nadeau <[email protected]>
À : JC <[email protected]>
Cc : [email protected]
Envoyé le : Sam 2 Janvier 2010, 2 h 40 min 14 s
Objet : Re: [Agar] Re : Scrollview with AG_ObjectFreeChildren


It seems your e-mail client has mangled the code again? I can't make
sense out of it.

On Fri, Jan 01, 2010 at 03:56:45PM -0800, JC wrote:
> I had a second question because they are linked.
> 
> If I just change the last function of the code to :
> void
> {executeAction(AG_Event 
> *event)//AG_ObjectFreeChildren(sv);AG_TextMsg(AG_MSG_WARNING, 
> AG_ButtonNew(sv, 0, 
> AG_WidgetUpdate(sv);
> }
> So when I put on the button "Ajouter" I should se a new button identified by 
> the incremented number "Compteur". But when I test it, the first put on 
> Ajouter doesn't make appear any button, the second put makes appear he button 
> 0 whereas it should be 1 and each following call make appear the button N-1 
> with the text "Button N added, you should see it". But if I add the button on 
> the window directly there is no problem, it happens only when I had it on the 
> scrollview.
>  
> So I have the same question, is it a bug or a mystake from me ? Is there a 
> solution to obtain the result I am waiting (a dynamic content scrollview) ?
>  
> Thanks a lot for your time, best regards and I wish that my english is 
> understandable ;)
> JC
> "Button %d added, you should see it", compteur);"Foo %d", compteur++); 
> 
> 
> 
> ________________________________
> De : JC <[email protected]>
> À : [email protected]
> Envoyé le : Sam 2 Janvier 2010, 0 h 00 min 43 s
> Objet : [Agar] Scrollview with AG_ObjectFreeChildren
> 
> 
> Hello,
> 
> I try to do a dynamic scrollview, so for each update I want to clean my 
> instance of scrollview, I put what I want in et update. But I get an segment 
> fault exception. I have been able to reproduce the problem on the agar demo 
> of scrollview wich I have juste a little modified the source code.
> 
> So if you compile the code joined to this email you will get a scrollview 
> with an "Ajouter" button, if you click on it the exception occurs.
> 
> Do I something wrong or is it an Agar bug please ?
> 
> Here is the code :
> 
> /* Public domain */
> /*
> * This application demonstrates the use of the AG_Scrollview(3) widget.
> */#include<agar/core.h>#include<agar/gui.h>AG_Scrollview 
> *sv;voidexecuteAction(AG_Event *event);intmain(
> {
> AG_Window *win;
> AG_Box *hBox;
> fprintf(stderr, 
> }
> printf(
> AG_SetBool(agConfig, 
> guiFlags |= AG_VIDEO_OPENGL;
> } 
> printf(
> AG_SetBool(agConfig, 
> }
> }
> fprintf(stderr, 
> }
> AG_BindGlobalKey(SDLK_ESCAPE, KMOD_NONE, AG_Quit);
> AG_BindGlobalKey(SDLK_F8, KMOD_NONE, AG_ViewCapture);
> win = AG_WindowNew(0);
> AG_ButtonNew(win, 0, 
> sv = AG_ScrollviewNew(win, 0);
> AG_Expand(sv);
> AG_ButtonNewFn(win, 0, 
> AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 50, 50);
> AG_WindowShow(win);
> AG_EventLoop();
> AG_Destroy();
> }intargc, char*argv[])intguiFlags = AG_VIDEO_RESIZABLE;intx, 
> y;if(AG_InitCore("agar-scrollview-demo", 0) == -1) {"%s\n", 
> AG_GetError());return(1);if(argc > 1) {if(strcmp(argv[1], "-g") == 0) 
> {"Forcing GL mode\n");"view...opengl", 1);elseif(strcmp(argv[1], "-G") == 0) 
> {"Forcing FB mode\n");"view.opengl", 0);if(AG_InitVideo(640, 480, 32, 
> guiFlags) == -1) {"%s\n", AG_GetError());return(1);"Foo");"Ajouter", 
> executeAction, "");return(0);void
> {
> AG_ObjectFreeChildren(sv);
> AG_WidgetUpdate(sv);
> }
>  executeAction(AG_Event *event)
> 
> 
> 
>    
> _______________________________________________
> Agar mailing list
> [email protected]
> http://libagar.org/lists.html


      
#include <agar/core.h>
#include <agar/gui.h>

AG_Scrollview *sv;
AG_Window *win;

void executeAction1(AG_Event *event)
{
        AG_ObjectLock(sv);
        AG_ObjectFreeChildren(sv);
        AG_ObjectUnlock(sv);
        AG_WindowUpdate(win);
}

void executeAction2(AG_Event *event)
{
        AG_ObjectLock(sv);
        //AG_ObjectFreeChildren(sv);
        AG_ObjectUnlock(sv);
        AG_WindowUpdate(win);
}

void executeAction3(AG_Event *event)
{
        AG_ObjectLock(win);
        AG_ObjectFreeChildren(win);
        AG_ObjectUnlock(win);
        AG_WindowUpdate(win);
}

void executeAction4(AG_Event *event)
{
        AG_ObjectLock(win);
        //AG_ObjectFreeChildren(win);
        AG_ObjectUnlock(win);
        AG_WindowUpdate(win);
}

int main(int argc, char *argv[])
{
        if (AG_InitCore("agar-scrollview-demo", 0) == -1) {
                fprintf(stderr, "%s\n", AG_GetError());
                return (1);
        }
        
        if (AG_InitVideo(640, 480, 32, AG_VIDEO_RESIZABLE) == -1) {
                fprintf(stderr, "%s\n", AG_GetError());
                return (1);
        }

        AG_BindGlobalKey(SDLK_ESCAPE, KMOD_NONE, AG_Quit);
        AG_BindGlobalKey(SDLK_F8, KMOD_NONE, AG_ViewCapture);

        win = AG_WindowNew(0);

        sv = AG_ScrollviewNew(win, 0);
        AG_Expand(sv);
        AG_ButtonNew(sv, 0, "Do nothing");

        AG_ButtonNewFn(win, 0, "Action 1 : Clear Scrollview", executeAction1, 
"");
        AG_ButtonNewFn(win, 0, "Action 2 : Update Scrollview without freeing 
children", executeAction2, "");
        AG_ButtonNewFn(win, 0, "Action 3 : Clear Window", executeAction3, "");
        AG_ButtonNewFn(win, 0, "Action 4 : Update Window without freeing 
children", executeAction4, "");

        AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 50, 50);
        AG_WindowShow(win);
        
        AG_EventLoop();

        AG_Destroy();
        return (0);
}
_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html

Reply via email to