Sorry for the code missing. Attached are the 2 files :

  - problem 1, scrollview_ObjectFreeChildren.c : makes a memory read error 
AG_EventLoop() after having click on the button Ajouter. To comment the 
AG_ObjectFreeChildren makes all be ok (but of course I need to use it)

  - problem 2, scrollview_unsynchronized.c : when you click on Ajouter it adds 
the button identified by N-1 to the scrollview when it should add the button 
identified by N. Resizing the window make all be ok, so it should be a 
refreshing problem of the scrollview but there is a AG_WidgetUpdate function. 
Adding the button on the window instead of the scrollview makes all be ok...
 Best regards,
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


      
/*      Public domain   */
/*
 * This application demonstrates the use of the AG_Scrollview(3) widget.
 */
#include <agar/core.h>
#include <agar/gui.h>

AG_Scrollview *sv;
AG_Window *win;
int compteur;

void executeAction(AG_Event *event);

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

        if (argc > 1) {
                if (strcmp(argv[1], "-g") == 0) {
                        printf("Forcing GL mode\n");
                        AG_SetBool(agConfig, "view.opengl", 1);
                        guiFlags |= AG_VIDEO_OPENGL;
                } else if (strcmp(argv[1], "-G") == 0) {
                        printf("Forcing FB mode\n");
                        AG_SetBool(agConfig, "view.opengl", 0);
                }
        }
        
        if (AG_InitVideo(640, 480, 32, guiFlags) == -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_ButtonNewFn(win, 0, "Ajouter", executeAction, "");

        AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 50, 50);
        AG_WindowShow(win);
        
        AG_EventLoop();
        AG_Destroy();
        return (0);
}

void executeAction(AG_Event *event)
{
        AG_ObjectFreeChildren(sv);
        //AG_TextMsg(AG_MSG_WARNING, "Button %d added, you should see it", 
compteur);
        //AG_ButtonNew(sv, 0, "Foo %d", compteur++);
        AG_WidgetUpdate(sv);
}


/*      Public domain   */
/*
 * This application demonstrates the use of the AG_Scrollview(3) widget.
 */
#include <agar/core.h>
#include <agar/gui.h>

AG_Scrollview *sv;
AG_Window *win;
int compteur;

void executeAction(AG_Event *event);

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

        if (argc > 1) {
                if (strcmp(argv[1], "-g") == 0) {
                        printf("Forcing GL mode\n");
                        AG_SetBool(agConfig, "view.opengl", 1);
                        guiFlags |= AG_VIDEO_OPENGL;
                } else if (strcmp(argv[1], "-G") == 0) {
                        printf("Forcing FB mode\n");
                        AG_SetBool(agConfig, "view.opengl", 0);
                }
        }
        
        if (AG_InitVideo(640, 480, 32, guiFlags) == -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_ButtonNewFn(win, 0, "Ajouter", executeAction, "");

        AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 50, 50);
        AG_WindowShow(win);
        
        AG_EventLoop();
        AG_Destroy();
        return (0);
}

void executeAction(AG_Event *event)
{
        //AG_ObjectFreeChildren(sv);
        AG_TextMsg(AG_MSG_WARNING, "Button %d added, you should see it", 
compteur);
        AG_ButtonNew(sv, 0, "Foo %d", compteur++);
        AG_WidgetUpdate(sv);
}


_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html

Reply via email to