[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2192.0. "Callback list GetValue broken?" by RHETT::BONNE () Fri Feb 02 1990 13:54

Below is a program that demonstrates a bug with the callback mechanism.
Basically, I'm trying to get the callback list from various widgets.  I
can get the callback list for Destroy and Help, but *none* of
the others seems to work..  In this program I stuff a few proc/tags in the
Destroy callback and can get those out wonderfully.  But I do the same thing
with the Map callback and the arguement list that comes back is corrupted.
(See comments in code..) 

Is there a better way to get back the callback list?  Is this a bug?
All the callbacks work fine, I just can't see them!
Thanks- Jim
_____________________________________________________________
#include <stdio.h>
#include <X11/DwtAppl.h>

void FunStuff();
void DumbStuff();
void test_routine();

Widget        toplevel;
Widget        dialogBox;

main()
{
    static Arg arglist[10];
    int        argc = 0;

    toplevel = XtInitialize("Test Window",
                            "demo",
                            NULL,
                            0,
                            &argc,
                            NULL);
                 
    XtSetArg(arglist[0], DwtNwidth, 250);
    XtSetArg(arglist[1], DwtNheight, 250);

    dialogBox = DwtDialogBoxCreate(toplevel, "fun", arglist, 2);

    XtManageChild(dialogBox);

    XtRealizeWidget(toplevel);
    XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel), 1000, test_routine,
NULL);
    XtMainLoop();
}

void test_routine()
{
    Arg a1[1];

static    DwtCallbackPtr callback_list = NULL;
static    DwtCallback    callback_data[3];
static    DwtCallbackPtr callback_ptr = callback_data;

    /*****
     * Use dbx to check what's in the DESTROY callback_list right now.
     * It should be nil...
     *****/
    XtSetArg(a1[0], DwtNdestroyCallback, &callback_list);
    XtGetValues(dialogBox, a1, 1);

    /*****
     * Alter the DESTROY callback_list
     *****/
    callback_ptr[0].proc = FunStuff;
    callback_ptr[0].tag = 123;
    callback_ptr[1].proc = DumbStuff;
    callback_ptr[1].tag = 666;
    callback_ptr[2].proc = NULL;
    XtSetArg(a1[0], DwtNdestroyCallback, callback_ptr);
    XtSetValues(dialogBox, a1, 1);

    callback_list = NULL;
    XtSetArg(a1[0], DwtNdestroyCallback, &callback_list);
    XtGetValues(dialogBox, a1, 1);
    /*****
     * Check to see what's in the DESTROY callback_list now.
     * It should have callback_list pointing to the data structure with
     * [0] being the proc and tag for FunStuff, [1] being proc and tag
     * for DumbStuff and [2] being nil (terminating list) Okay.
     *****/
                                                                 
    /*****
     * Now try the same thing with the MAP callback_list.  The
     * results will be very different.
     *****/
    callback_list = NULL;
    XtSetArg(a1[0], DwtNmapCallback, &callback_list);
    XtGetValues(dialogBox, a1, 1);

    callback_ptr[0].proc = FunStuff;
    callback_ptr[0].tag = 123;
    callback_ptr[1].proc = DumbStuff;
    callback_ptr[1].tag = 666;
    callback_ptr[2].proc = NULL;
    XtSetArg(a1[0], DwtNmapCallback, callback_ptr);
    XtSetValues(dialogBox, a1, 1);

    callback_list = NULL;
    XtSetArg(a1[0], DwtNmapCallback, &callback_list);
    XtGetValues(dialogBox, a1, 1);

   /*********
    * Now looking at callback_list structure you get the following:
    * [0] has a proc and tag, [1] has his first addition, [2] and [3]
    * are nil and [4] has his second addition, then [5] and above are
    * nil.... strange callback list return! What am I doing wrong???
   ********/
}

void FunStuff(w, tag, callback_ptr)
  Widget w;
  int *tag;
  DwtAnyCallbackStruct *callback_ptr;
{
    printf("FUNSTUFF:Hello there\n");
}

void DumbStuff(w, tag, callback_ptr)
  Widget w;
  int *tag;
  DwtAnyCallbackStruct *callback_ptr;
{
    printf("DUMBSTUFF:Hello there\n");
}
T.RTitleUserPersonal
Name
DateLines