When calling "XCloseDisplay" Core dump occuring - Xwindows

This is a discussion on When calling "XCloseDisplay" Core dump occuring - Xwindows ; Hi folks, I have a java Applet which is running in browser and from that Applet I called a Widget Window to do some process. Everything worked fine except the close of widget.. For closing that widget I have a ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: When calling "XCloseDisplay" Core dump occuring

  1. When calling "XCloseDisplay" Core dump occuring

    Hi folks,
    I have a java Applet which is running in browser and from that Applet
    I called a Widget Window to do some process. Everything worked fine
    except the close of widget..
    For closing that widget I have a MessageBox of

    system("xmessage -default No -nearmouse -center -print -buttons
    Yes:2,No:3 Close MyWidget?");

    and if clicked on the MessageBox 'Yes' ,I Called MyWidgetWindow's
    Close function.

    But when I tried to close that Widget entire **browser get **closed.
    Pls look into my code and
    My close Function

    void MyWidgetWindow::Close()
    {
    try{
    close(mypipe[0]);
    close(mypipe[1]);
    PipeReader->stop();
    delete[] orgPixBuff ;
    orgPixBuff=NULL;
    delete PipeReader;
    PipeReader = NULL;

    XFreePixmap(display, dis_backup);
    XFreeGC( display,gc);
    XUnmapWindow(display,window);
    XDestroyWindow( display,window);
    XFlush(display);
    XCloseDisplay(display);//*****HERE CORE DUMP OCCURING
    //XtCloseDispaly(display);
    }
    catch(...)
    {
    system("xmessage -default No -nearmouse -center -print
    -buttons Yes:2 Exception");
    }
    }


    and my code is like this.



    void MyWidgetWindow::buttonHandler(Widget w, XtPointer data, XEvent
    *ev, Boolean *cont)
    {
    switch (ev->type)
    {
    //some process
    }
    };

    void MyWidgetWindow::MainLoop()
    {
    XEvent ev;
    while (stopflag!= true)
    {
    XtNextEvent(&ev);
    XtDispatchEvent(&ev);
    }
    return ;
    }

    int MyWidgetWindow::IOErrorHandler( Display *dpy)
    {
    printf( "error\n" );
    return 0;
    }

    void MyWidgetWindow::CreateAnnWindow()
    {
    Widget toplevel,lineButton,drawing ....
    int n;
    Arg wargs[10];
    int temparg =1;
    char* temargv[]= {"./Test Program"};
    bool serverAnnotationFlag = true;
    toplevel = XtInitialize(temargv[0],"drawing", NULL, 0, &temparg,
    temargv);
    box = XtCreateManagedWidget("box", formWidgetClass, toplevel, NULL,
    0);

    lineButton = XtVaCreateManagedWidget("Line", commandWidgetClass,
    box, XtNlabel," Line ",NULL);
    circleButton = XtVaCreateManagedWidget("Circle", commandWidgetClass,
    box,XtNfromHoriz,lineButton,NULL);
    " " //SOME OTHERS WIDGETS FOR DRAWING LINE CIRCLE...AND FOR COLOR
    CHANGE...
    " "

    drawing = XtCreateManagedWidget("drawing",coreWidgetClass, box, NULL,
    0);

    pipeReader(); //CRETING A PIPE FOR READING AND WRITING
    CONTINUES DATA
    n = 0;
    XtSetArg(wargs[n], XtNheight, SCR_HEIGHT ); n++;
    XtSetArg(wargs[n], XtNwidth, SCR_WIDTH); n++;
    XtSetValues(drawing, wargs, n);
    XtAddEventHandler(drawing, ExposureMask, FALSE,
    (XtEventHandler)redisplay_event, NULL);
    XtAddEventHandler( drawing, ExposureMask, FALSE, exposeHandler, NULL
    );

    orgPixBuff = new char[ pBuffer->scrWidth * pBuffer->scrHeight *
    pBuffer->secondarybpp];
    memcpy(orgPixBuff,pBuffer->newscr_buff,pBuffer->scrWidth *
    pBuffer->scrHeight * pBuffer->secondarybpp);

    XtRealizeWidget(toplevel); //REALIZING WIDGET

    XtAddEventHandler(drawing, KeyPressMask | ButtonPressMask |
    ButtonReleaseMask | StructureNotifyMask | ButtonMotionMask,
    FALSE, buttonHandler, NULL);
    XtAddCallback(lineButton, XtNcallback,
    (XtCallbackProc)lineButtonHandler,(XtPointer)drawi ng);
    XtAddCallback(circleButton, XtNcallback,circleButtonHandler,
    (XtPointer)drawing);

    XSetIOErrorHandler(IOErrorHandler);
    if (setjmp(env)) setjmp(env);

    MainLoop(); //MAIN LOOP

    }

    void MyWidgetWindow::draw_graphics(Widget w)
    {
    XGCValues values;
    display = XtDisplay(w);
    dpy_count++;
    window = XtWindow(w);
    alter_these_mask = ExposureMask|GCSubwindowMode | GCForeground|
    GCBackground;
    strncpy(PEN_COLOR, "black", 40);
    XAllocNamedColor(display, DefaultColormap(display,
    DefaultScreen(display)), PEN_COLOR, &scrn_def_ret, &exact_def_ret);

    scr = DefaultScreenOfDisplay(display);
    screen = DefaultScreen(display);
    attr.background_pixel = WhitePixel(display,screen);
    attr.event_mask = ButtonPressMask | ExposureMask;
    gcvalues.foreground = scrn_def_ret.pixel;
    gcvalues.background = WhitePixel(display, DefaultScreen(display));
    gc =XCreateGC(display, window , 0 , &values);
    XMapWindow(display, window);

    XSetLineAttributes(display, gc,2, 0, 0, 0);
    xImage = XGetImage(display, RootWindowOfScreen(scr), 0, 0,SCR_WIDTH,
    SCR_HEIGHT, AllPlanes, ZPixmap);
    memcpy(xImage->data,pBuffer->newscr_buff,pBuffer->scrWidth *
    pBuffer->scrHeight * pBuffer->secondarybpp);

    dis_backup = XCreatePixmap(display, window, SCR_WIDTH, SCR_HEIGHT,
    XDefaultDepth(display, screen));
    XPutImage(display, dis_backup , DefaultGC(display,screen), xImage, 0,
    0, 0, 0, SCR_WIDTH, SCR_HEIGHT);
    XCopyArea(display, dis_backup,window, DefaultGC(display,screen), 0,
    0, SCR_WIDTH, SCR_HEIGHT, 0, 0);
    XFlush(display);
    }


    void MyWidgetWindow::lineButtonHandler(Widget w, XtPointer callData,
    XtPointer clientData)
    {
    //SOME PROCCESSES
    };


    void MyWidgetWindow :: redisplay_event(Widget w,XtPointer
    client,XExposeEvent * ev)
    {
    if(ev->count != 0)
    return;
    if(count1 == 0)
    {
    draw_graphics(w);
    count1 =1;
    }
    }

    void MyWidgetWindow ::exposeHandler( Widget w, XtPointer data, XEvent
    *event, Boolean *cont)
    {
    XExposeEvent *ev = (XExposeEvent *)event;
    if(display !=NULL && gc != NULL)
    {
    XCopyArea(display, dis_backup, window, gc,ev->x, ev->y, ev->width,
    ev->height,ev->x, ev->y);// 0, 0, SCR_WIDTH, SCR_HEIGHT, 0, 0);
    }
    }




    some one pls tell me where Iam wrong..
    Thnx in advance
    Anil

  2. Re: When calling "XCloseDisplay" Core dump occuring

    anil_sgs@rediffmail.com (anil) wrote in
    news:d64119d2.0307040329.21f9b1a4@posting.google.c om:
    > I have a java Applet which is running in browser and from that Applet
    > I called a Widget Window to do some process. Everything worked fine
    > except the close of widget..


    Sounds like memory corruption elsewhere in your program.

    Ken Lee, http://www.rahul.net/kenton/

  3. Re: When calling "XCloseDisplay" Core dump occuring

    anil wrote:

    > I have a java Applet which is running in browser and from that Applet
    > I called a Widget Window to do some process. Everything worked fine
    > except the close of widget..
    > For closing that widget I have a MessageBox of
    >
    > system("xmessage -default No -nearmouse -center -print -buttons
    > Yes:2,No:3 Close MyWidget?");
    >
    > and if clicked on the MessageBox 'Yes' ,I Called MyWidgetWindow's
    > Close function.
    >
    > But when I tried to close that Widget entire **browser get **closed.
    > Pls look into my code and

    [code]

    From where do you get your Display? Do you open a independent connection
    or do you get delivered it from somewhere, e.g. by calling XtDisplay()
    with a known Widget? In the last case, when you share the Display, you
    pull away the Display under the browsers behind, so the browser cannot use
    the Display anymore.

    Regards,
    Daniel

+ Reply to Thread