query on XtVaGetValues - Motif

This is a discussion on query on XtVaGetValues - Motif ; Hi, I am having GUI application built on HPUX ia64. XtVaGetValues( w, XmNuserData, &fop, 0 ); "&fop" has to return the option selected in the widget but it always returns 0 whatever is the option.Any clue.Or if there is any ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: query on XtVaGetValues

  1. query on XtVaGetValues

    Hi,

    I am having GUI application built on HPUX ia64.

    XtVaGetValues( w, XmNuserData, &fop, 0 );

    "&fop" has to return the option selected in the widget but it always
    returns 0 whatever is the option.Any clue.Or if there is any workaround
    to get the XmNuserData information...


    Some code snippets.
    -------------------------------
    Widget pb = XtVaCreateManagedWidget(
    label.c_str(),
    xmPushButtonWidgetClass, _operators_pd,
    XmNuserData,(*foi),
    NULL );

    void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer s )
    {
    FilterOperator fop;
    XtVaGetValues( w, XmNuserData, &fop, 0 );
    cout << "fop is " << fop << endl; //bug....always
    returns 0?
    ((FilterWidget*)d)->Operator( fop );
    }


    Thanks in advance,
    Mehaboob


  2. Re: query on XtVaGetValues

    mehaboob@gmail.com wrote:

    > Widget pb = XtVaCreateManagedWidget(
    > label.c_str(),
    > xmPushButtonWidgetClass, _operators_pd,
    > XmNuserData,(*foi),
    > NULL );


    XmNuserData is only meant for pointers. You can't put anything bigger
    than that inside, and you can't put objects inside it (they won't run
    constructors, etc.). You probably want:

    FilterOperator *foi = new FilterOperator;

    Widget pb = XtVaCreateManagedWidget(
    label.c_str(),
    xmPushButtonWidgetClass, _operators_pd,
    XmNuserData, foi, NULL);

    > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer s )
    > {
    > FilterOperator fop;
    > XtVaGetValues( w, XmNuserData, &fop, 0 );
    > cout << "fop is " << fop << endl; //bug....always
    > returns 0?
    > ((FilterWidget*)d)->Operator( fop );
    > }


    Probably:

    FilterOperator *fop;
    XtVaGetValues(w, XmNuserData, &fop, NULL);
    cout << "fop is " << *fop << endl;
    ((FilterWidget*)d)->Operator(*fop);

    ....and then delete your FilterOperator pointer when the widget is destroyed.

  3. Re: query on XtVaGetValues


    ST wrote:
    > mehaboob@gmail.com wrote:
    >
    > > Widget pb = XtVaCreateManagedWidget(
    > > label.c_str(),
    > > xmPushButtonWidgetClass, _operators_pd,
    > > XmNuserData,(*foi),
    > > NULL );

    >
    > XmNuserData is only meant for pointers. You can't put anything bigger
    > than that inside, and you can't put objects inside it (they won't run
    > constructors, etc.). You probably want:
    >
    > FilterOperator *foi = new FilterOperator;
    >
    > Widget pb = XtVaCreateManagedWidget(
    > label.c_str(),
    > xmPushButtonWidgetClass, _operators_pd,
    > XmNuserData, foi, NULL);
    >
    > > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer s )
    > > {
    > > FilterOperator fop;
    > > XtVaGetValues( w, XmNuserData, &fop, 0 );
    > > cout << "fop is " << fop << endl; //bug....always
    > > returns 0?
    > > ((FilterWidget*)d)->Operator( fop );
    > > }

    >
    > Probably:
    >
    > FilterOperator *fop;
    > XtVaGetValues(w, XmNuserData, &fop, NULL);
    > cout << "fop is " << *fop << endl;
    > ((FilterWidget*)d)->Operator(*fop);
    >
    > ...and then delete your FilterOperator pointer when the widget is destroyed.


    Hi Thanks for the reply,

    FilterOperator is defined in the code as
    typedef enum {
    GreaterThan,
    LessThan,
    GreaterThanOrEqual,
    LessThanOrEqual,
    Equals,
    NotEquals,
    Contains, // For string compares.
    DoesNotContain, // For string compares.
    NoOperator
    } FilterOperator;

    And the foi goes as follows,
    for ( vector::const_iterator foi =
    operators.begin();foi != operators.end(); ++foi )
    {
    string label;
    switch ( (int)(*foi) )
    {
    case GreaterThan: label = ">"; break;
    case LessThan: label = "<"; break;
    case GreaterThanOrEqual: label = ">="; break;
    case LessThanOrEqual: label = "<="; break;
    case Equals: label = "="; break;
    case NotEquals: label = "!="; break;
    case Contains: label = "C"; break;
    case DoesNotContain: label = "!C"; break;
    default:
    case NoOperator: label = "?"; break;
    }

    Widget pb = XtVaCreateManagedWidget(
    label.c_str(),
    xmPushButtonWidgetClass, _operators_pd,
    XmNuserData, (*foi),
    NULL );

    Am not sure if I can use a pointer and then iterate through
    FilterOperator?
    How do I do that?

    Thanks in advance,
    Mehaboob


  4. Re: query on XtVaGetValues

    > Am not sure if I can use a pointer and then iterate through
    > FilterOperator? How do I do that?


    Convert the iterator to a pointer.

    Note the data type of "XmNuserData" is XtPointer, not FilterOperator.
    So, you're are putting a nonpointer value into a 64-bit pointer slot
    without a cast, and hoping that the addresses are the same. That
    doesn't work if they're differently sized.

  5. Re: query on XtVaGetValues


    wrote in message
    news:1157646129.545875.206490@b28g2000cwb.googlegr oups.com...
    >
    > ST wrote:
    >> mehaboob@gmail.com wrote:
    >>
    >> > Widget pb = XtVaCreateManagedWidget(
    >> > label.c_str(),
    >> > xmPushButtonWidgetClass, _operators_pd,
    >> > XmNuserData,(*foi),
    >> > NULL );

    >>
    >> XmNuserData is only meant for pointers. You can't put anything bigger
    >> than that inside, and you can't put objects inside it (they won't run
    >> constructors, etc.). You probably want:
    >>
    >> FilterOperator *foi = new FilterOperator;
    >>
    >> Widget pb = XtVaCreateManagedWidget(
    >> label.c_str(),
    >> xmPushButtonWidgetClass, _operators_pd,
    >> XmNuserData, foi, NULL);


    The XmNuserData value that you specify here is a pointer, of type "Filter
    Operator *".
    This is OK, since XmNuserData is an XtPointer, and thus can hold any
    pointer.

    >>
    >> > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer s )
    >> > {
    >> > FilterOperator fop;
    >> > XtVaGetValues( w, XmNuserData, &fop, 0 );


    The above is wrong - you need to pass the address of an XtPointer to
    XtVaGetValues
    when retrieving XmNuserData, since you set it equal to a pointer:

    XtPointer temp;
    FilterOperator *pfop;
    XtVaGetValues( w, XmNuserData, &temp, NULL );
    pfop = (FilterOperator *)temp;

    ... then use pfop as a pointer to a FilterOperator.


    > Thanks in advance,
    > Mehaboob
    >

    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project



  6. Re: query on XtVaGetValues

    Whatever be the case.
    u can get it only as

    FilterOperator *pfop;
    XtVaGetValues( w, XmNuserData, &temp, NULL );




    Fred Kleinschmidt wrote:
    > wrote in message
    > news:1157646129.545875.206490@b28g2000cwb.googlegr oups.com...
    > >
    > > ST wrote:
    > >> mehaboob@gmail.com wrote:
    > >>
    > >> > Widget pb = XtVaCreateManagedWidget(
    > >> > label.c_str(),
    > >> > xmPushButtonWidgetClass, _operators_pd,
    > >> > XmNuserData,(*foi),
    > >> > NULL );
    > >>
    > >> XmNuserData is only meant for pointers. You can't put anything bigger
    > >> than that inside, and you can't put objects inside it (they won't run
    > >> constructors, etc.). You probably want:
    > >>
    > >> FilterOperator *foi = new FilterOperator;
    > >>
    > >> Widget pb = XtVaCreateManagedWidget(
    > >> label.c_str(),
    > >> xmPushButtonWidgetClass, _operators_pd,
    > >> XmNuserData, foi, NULL);

    >
    > The XmNuserData value that you specify here is a pointer, of type "Filter
    > Operator *".
    > This is OK, since XmNuserData is an XtPointer, and thus can hold any
    > pointer.
    >
    > >>
    > >> > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer s )
    > >> > {
    > >> > FilterOperator fop;
    > >> > XtVaGetValues( w, XmNuserData, &fop, 0 );

    >
    > The above is wrong - you need to pass the address of an XtPointer to
    > XtVaGetValues
    > when retrieving XmNuserData, since you set it equal to a pointer:
    >
    > XtPointer temp;
    > FilterOperator *pfop;
    > XtVaGetValues( w, XmNuserData, &temp, NULL );
    > pfop = (FilterOperator *)temp;
    >
    > ... then use pfop as a pointer to a FilterOperator.
    >
    >
    > > Thanks in advance,
    > > Mehaboob
    > >

    > --
    > Fred L. Kleinschmidt
    > Boeing Associate Technical Fellow
    > Technical Architect, Software Reuse Project



  7. Re: query on XtVaGetValues


    "Twister.Net" wrote in message
    news:1157658098.617082.318040@i42g2000cwa.googlegr oups.com...
    > Whatever be the case.
    > u can get it only as
    >
    > FilterOperator *pfop;
    > XtVaGetValues( w, XmNuserData, &temp, NULL );
    >

    I think you meant
    XtVaGetValues( w, XmNuserData, &pfop, NULL );

    But it is safer to use
    XtPointer temp;
    FilterOperator *pfop;
    XtVaGetValues( w, XmNuserData, &temp, NULL );


    so the compiler can warn you about possible incompatible pointer casts
    >
    >
    >
    > Fred Kleinschmidt wrote:
    >> wrote in message
    >> news:1157646129.545875.206490@b28g2000cwb.googlegr oups.com...
    >> >
    >> > ST wrote:
    >> >> mehaboob@gmail.com wrote:
    >> >>
    >> >> > Widget pb = XtVaCreateManagedWidget(
    >> >> > label.c_str(),
    >> >> > xmPushButtonWidgetClass, _operators_pd,
    >> >> > XmNuserData,(*foi),
    >> >> > NULL );
    >> >>
    >> >> XmNuserData is only meant for pointers. You can't put anything bigger
    >> >> than that inside, and you can't put objects inside it (they won't run
    >> >> constructors, etc.). You probably want:
    >> >>
    >> >> FilterOperator *foi = new FilterOperator;
    >> >>
    >> >> Widget pb = XtVaCreateManagedWidget(
    >> >> label.c_str(),
    >> >> xmPushButtonWidgetClass, _operators_pd,
    >> >> XmNuserData, foi, NULL);

    >>
    >> The XmNuserData value that you specify here is a pointer, of type "Filter
    >> Operator *".
    >> This is OK, since XmNuserData is an XtPointer, and thus can hold any
    >> pointer.
    >>
    >> >>
    >> >> > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer s )
    >> >> > {
    >> >> > FilterOperator fop;
    >> >> > XtVaGetValues( w, XmNuserData, &fop, 0 );

    >>
    >> The above is wrong - you need to pass the address of an XtPointer to
    >> XtVaGetValues
    >> when retrieving XmNuserData, since you set it equal to a pointer:
    >>
    >> XtPointer temp;
    >> FilterOperator *pfop;
    >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    >> pfop = (FilterOperator *)temp;
    >>
    >> ... then use pfop as a pointer to a FilterOperator.
    >>
    >>
    >> > Thanks in advance,
    >> > Mehaboob
    >> >

    >> --
    >> Fred L. Kleinschmidt
    >> Boeing Associate Technical Fellow
    >> Technical Architect, Software Reuse Project

    >




  8. Re: query on XtVaGetValues


    Fred Kleinschmidt wrote:

    > "Twister.Net" wrote in message
    > news:1157658098.617082.318040@i42g2000cwa.googlegr oups.com...
    > > Whatever be the case.
    > > u can get it only as
    > >
    > > FilterOperator *pfop;
    > > XtVaGetValues( w, XmNuserData, &temp, NULL );
    > >

    > I think you meant
    > XtVaGetValues( w, XmNuserData, &pfop, NULL );
    >
    > But it is safer to use
    > XtPointer temp;
    > FilterOperator *pfop;
    > XtVaGetValues( w, XmNuserData, &temp, NULL );
    >
    >
    > so the compiler can warn you about possible incompatible pointer casts
    > >
    > >
    > >
    > > Fred Kleinschmidt wrote:
    > >> wrote in message
    > >> news:1157646129.545875.206490@b28g2000cwb.googlegr oups.com...
    > >> >
    > >> > ST wrote:
    > >> >> mehaboob@gmail.com wrote:
    > >> >>
    > >> >> > Widget pb = XtVaCreateManagedWidget(
    > >> >> > label.c_str(),
    > >> >> > xmPushButtonWidgetClass, _operators_pd,
    > >> >> > XmNuserData,(*foi),
    > >> >> > NULL );
    > >> >>
    > >> >> XmNuserData is only meant for pointers. You can't put anything bigger
    > >> >> than that inside, and you can't put objects inside it (they won't run
    > >> >> constructors, etc.). You probably want:
    > >> >>
    > >> >> FilterOperator *foi = new FilterOperator;
    > >> >>
    > >> >> Widget pb = XtVaCreateManagedWidget(
    > >> >> label.c_str(),
    > >> >> xmPushButtonWidgetClass, _operators_pd,
    > >> >> XmNuserData, foi, NULL);
    > >>
    > >> The XmNuserData value that you specify here is a pointer, of type "Filter
    > >> Operator *".
    > >> This is OK, since XmNuserData is an XtPointer, and thus can hold any
    > >> pointer.
    > >>
    > >> >>
    > >> >> > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer s )
    > >> >> > {
    > >> >> > FilterOperator fop;
    > >> >> > XtVaGetValues( w, XmNuserData, &fop, 0 );
    > >>
    > >> The above is wrong - you need to pass the address of an XtPointer to
    > >> XtVaGetValues
    > >> when retrieving XmNuserData, since you set it equal to a pointer:
    > >>
    > >> XtPointer temp;
    > >> FilterOperator *pfop;
    > >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    > >> pfop = (FilterOperator *)temp;
    > >>
    > >> ... then use pfop as a pointer to a FilterOperator.
    > >>
    > >>
    > >> > Thanks in advance,
    > >> > Mehaboob
    > >> >
    > >> --
    > >> Fred L. Kleinschmidt
    > >> Boeing Associate Technical Fellow


    Hi,

    Thanks a lot for the reply.
    I tried the below method as mentioned by you to fetch the value.

    XtPointer temp;
    FilterOperator *pfop;
    XtVaGetValues( w, XmNuserData, &temp, NULL );
    pfop = (FilterOperator *)temp;

    It fetches the value but I have to pass it to another function which
    expects input of type FilterOperator and hence results in compilation
    error.

    function:
    ((FilterWidget*)d)->Operator( pfop );

    Compliation Error:
    "../src/FilterWidget.cxx", line 582: error #2304: no instance of
    overloaded function "FilterWidget::Operator" matches the argment list

    I cannot change the input type as it is used in many places.
    Is it possible to convert pfop as FilterOperator and pass it to
    function.

    Mehaboob


  9. Re: query on XtVaGetValues

    mehaboob@gmail.com wrote:

    > Is it possible to convert pfop as FilterOperator and pass it to
    > function.


    ((FilterWidget*)d)->Operator(*pfop);

    You might want to read up on how pointers work, as you're not going to
    get very much further if this is a surprise.

  10. Re: query on XtVaGetValues


    wrote in message
    news:1157670839.367995.273240@i42g2000cwa.googlegr oups.com...
    >
    > Fred Kleinschmidt wrote:
    >
    >> "Twister.Net" wrote in message
    >> news:1157658098.617082.318040@i42g2000cwa.googlegr oups.com...
    >> > Whatever be the case.
    >> > u can get it only as
    >> >
    >> > FilterOperator *pfop;
    >> > XtVaGetValues( w, XmNuserData, &temp, NULL );
    >> >

    >> I think you meant
    >> XtVaGetValues( w, XmNuserData, &pfop, NULL );
    >>
    >> But it is safer to use
    >> XtPointer temp;
    >> FilterOperator *pfop;
    >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    >>
    >>
    >> so the compiler can warn you about possible incompatible pointer casts
    >> >
    >> >
    >> >
    >> > Fred Kleinschmidt wrote:
    >> >> wrote in message
    >> >> news:1157646129.545875.206490@b28g2000cwb.googlegr oups.com...
    >> >> >
    >> >> > ST wrote:
    >> >> >> mehaboob@gmail.com wrote:
    >> >> >>
    >> >> >> > Widget pb = XtVaCreateManagedWidget(
    >> >> >> > label.c_str(),
    >> >> >> > xmPushButtonWidgetClass, _operators_pd,
    >> >> >> > XmNuserData,(*foi),
    >> >> >> > NULL );
    >> >> >>
    >> >> >> XmNuserData is only meant for pointers. You can't put anything
    >> >> >> bigger
    >> >> >> than that inside, and you can't put objects inside it (they won't
    >> >> >> run
    >> >> >> constructors, etc.). You probably want:
    >> >> >>
    >> >> >> FilterOperator *foi = new FilterOperator;
    >> >> >>
    >> >> >> Widget pb = XtVaCreateManagedWidget(
    >> >> >> label.c_str(),
    >> >> >> xmPushButtonWidgetClass, _operators_pd,
    >> >> >> XmNuserData, foi, NULL);
    >> >>
    >> >> The XmNuserData value that you specify here is a pointer, of type
    >> >> "Filter
    >> >> Operator *".
    >> >> This is OK, since XmNuserData is an XtPointer, and thus can hold any
    >> >> pointer.
    >> >>
    >> >> >>
    >> >> >> > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer
    >> >> >> > s )
    >> >> >> > {
    >> >> >> > FilterOperator fop;
    >> >> >> > XtVaGetValues( w, XmNuserData, &fop, 0 );
    >> >>
    >> >> The above is wrong - you need to pass the address of an XtPointer to
    >> >> XtVaGetValues
    >> >> when retrieving XmNuserData, since you set it equal to a pointer:
    >> >>
    >> >> XtPointer temp;
    >> >> FilterOperator *pfop;
    >> >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    >> >> pfop = (FilterOperator *)temp;
    >> >>
    >> >> ... then use pfop as a pointer to a FilterOperator.
    >> >>
    >> >>
    >> >> > Thanks in advance,
    >> >> > Mehaboob
    >> >> >
    >> >> --
    >> >> Fred L. Kleinschmidt
    >> >> Boeing Associate Technical Fellow

    >
    > Hi,
    >
    > Thanks a lot for the reply.
    > I tried the below method as mentioned by you to fetch the value.
    >
    > XtPointer temp;
    > FilterOperator *pfop;
    > XtVaGetValues( w, XmNuserData, &temp, NULL );
    > pfop = (FilterOperator *)temp;
    >
    > It fetches the value but I have to pass it to another function which
    > expects input of type FilterOperator and hence results in compilation
    > error.
    >
    > function:
    > ((FilterWidget*)d)->Operator( pfop );
    >
    > Compliation Error:
    > "../src/FilterWidget.cxx", line 582: error #2304: no instance of
    > overloaded function "FilterWidget::Operator" matches the argment list
    >
    > I cannot change the input type as it is used in many places.
    > Is it possible to convert pfop as FilterOperator and pass it to
    > function.
    >
    > Mehaboob
    >


    Just pass *pfop instead of pfop

    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project



  11. Re: query on XtVaGetValues


    Fred Kleinschmidt wrote:

    > wrote in message
    > news:1157670839.367995.273240@i42g2000cwa.googlegr oups.com...
    > >
    > > Fred Kleinschmidt wrote:
    > >
    > >> "Twister.Net" wrote in message
    > >> news:1157658098.617082.318040@i42g2000cwa.googlegr oups.com...
    > >> > Whatever be the case.
    > >> > u can get it only as
    > >> >
    > >> > FilterOperator *pfop;
    > >> > XtVaGetValues( w, XmNuserData, &temp, NULL );
    > >> >
    > >> I think you meant
    > >> XtVaGetValues( w, XmNuserData, &pfop, NULL );
    > >>
    > >> But it is safer to use
    > >> XtPointer temp;
    > >> FilterOperator *pfop;
    > >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    > >>
    > >>
    > >> so the compiler can warn you about possible incompatible pointer casts
    > >> >
    > >> >
    > >> >
    > >> > Fred Kleinschmidt wrote:
    > >> >> wrote in message
    > >> >> news:1157646129.545875.206490@b28g2000cwb.googlegr oups.com...
    > >> >> >
    > >> >> > ST wrote:
    > >> >> >> mehaboob@gmail.com wrote:
    > >> >> >>
    > >> >> >> > Widget pb = XtVaCreateManagedWidget(
    > >> >> >> > label.c_str(),
    > >> >> >> > xmPushButtonWidgetClass, _operators_pd,
    > >> >> >> > XmNuserData,(*foi),
    > >> >> >> > NULL );
    > >> >> >>
    > >> >> >> XmNuserData is only meant for pointers. You can't put anything
    > >> >> >> bigger
    > >> >> >> than that inside, and you can't put objects inside it (they won't
    > >> >> >> run
    > >> >> >> constructors, etc.). You probably want:
    > >> >> >>
    > >> >> >> FilterOperator *foi = new FilterOperator;
    > >> >> >>
    > >> >> >> Widget pb = XtVaCreateManagedWidget(
    > >> >> >> label.c_str(),
    > >> >> >> xmPushButtonWidgetClass, _operators_pd,
    > >> >> >> XmNuserData, foi, NULL);
    > >> >>
    > >> >> The XmNuserData value that you specify here is a pointer, of type
    > >> >> "Filter
    > >> >> Operator *".
    > >> >> This is OK, since XmNuserData is an XtPointer, and thus can hold any
    > >> >> pointer.
    > >> >>
    > >> >> >>
    > >> >> >> > void FilterWidget::OperatorCB( Widget w, XtPointer d, XtPointer
    > >> >> >> > s )
    > >> >> >> > {
    > >> >> >> > FilterOperator fop;
    > >> >> >> > XtVaGetValues( w, XmNuserData, &fop, 0 );
    > >> >>
    > >> >> The above is wrong - you need to pass the address of an XtPointer to
    > >> >> XtVaGetValues
    > >> >> when retrieving XmNuserData, since you set it equal to a pointer:
    > >> >>
    > >> >> XtPointer temp;
    > >> >> FilterOperator *pfop;
    > >> >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    > >> >> pfop = (FilterOperator *)temp;
    > >> >>
    > >> >> ... then use pfop as a pointer to a FilterOperator.
    > >> >>
    > >> >>
    > >> >> > Thanks in advance,
    > >> >> > Mehaboob
    > >> >> >
    > >> >> --
    > >> >> Fred L. Kleinschmidt
    > >> >> Boeing Associate Technical Fellow

    > >
    > > Hi,
    > >
    > > Thanks a lot for the reply.
    > > I tried the below method as mentioned by you to fetch the value.
    > >
    > > XtPointer temp;
    > > FilterOperator *pfop;
    > > XtVaGetValues( w, XmNuserData, &temp, NULL );
    > > pfop = (FilterOperator *)temp;
    > >
    > > It fetches the value but I have to pass it to another function which
    > > expects input of type FilterOperator and hence results in compilation
    > > error.
    > >
    > > function:
    > > ((FilterWidget*)d)->Operator( pfop );
    > >
    > > Compliation Error:
    > > "../src/FilterWidget.cxx", line 582: error #2304: no instance of
    > > overloaded function "FilterWidget::Operator" matches the argment list
    > >
    > > I cannot change the input type as it is used in many places.
    > > Is it possible to convert pfop as FilterOperator and pass it to
    > > function.
    > >
    > > Mehaboob
    > >

    >
    > Just pass *pfop instead of pfop
    >
    > --
    > Fred L. Kleinschmidt
    > Boeing Associate Technical Fellow
    > Technical Architect, Software Reuse Project


    Thanks a lot for the reply.
    The reason why I asked about passing FilterOperator to the function is,

    Previously When I tried
    ((FilterWidget*)d)->Operator( *pfop );

    I get memory fault.
    pfop is 0000000000000005
    &pfop is 9fffffffffffde10
    Memory fault

    and the *pfop is points to the content stored at (0000000000000005)


  12. Re: query on XtVaGetValues


    wrote in message
    news:1157752416.864689.97230@e3g2000cwe.googlegrou ps.com...
    >
    > Fred Kleinschmidt wrote:
    >
    >> wrote in message
    >> news:1157670839.367995.273240@i42g2000cwa.googlegr oups.com...
    >> >
    >> > Fred Kleinschmidt wrote:
    >> >
    >> >> "Twister.Net" wrote in message
    >> >> news:1157658098.617082.318040@i42g2000cwa.googlegr oups.com...
    >> >> > Whatever be the case.
    >> >> > u can get it only as
    >> >> >
    >> >> > FilterOperator *pfop;
    >> >> > XtVaGetValues( w, XmNuserData, &temp, NULL );
    >> >> >
    >> >> I think you meant
    >> >> XtVaGetValues( w, XmNuserData, &pfop, NULL );
    >> >>
    >> >> But it is safer to use
    >> >> XtPointer temp;
    >> >> FilterOperator *pfop;
    >> >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    >> >>
    >> >>
    >> >> so the compiler can warn you about possible incompatible pointer
    >> >> casts
    >> >> >
    >> >> >
    >> >> >
    >> >> > Fred Kleinschmidt wrote:
    >> >> >> wrote in message
    >> >> >> news:1157646129.545875.206490@b28g2000cwb.googlegr oups.com...
    >> >> >> >
    >> >> >> > ST wrote:
    >> >> >> >> mehaboob@gmail.com wrote:
    >> >> >> >>
    >> >> >> >> > Widget pb = XtVaCreateManagedWidget(
    >> >> >> >> > label.c_str(),
    >> >> >> >> > xmPushButtonWidgetClass, _operators_pd,
    >> >> >> >> > XmNuserData,(*foi),
    >> >> >> >> > NULL );
    >> >> >> >>
    >> >> >> >> XmNuserData is only meant for pointers. You can't put anything
    >> >> >> >> bigger
    >> >> >> >> than that inside, and you can't put objects inside it (they
    >> >> >> >> won't
    >> >> >> >> run
    >> >> >> >> constructors, etc.). You probably want:
    >> >> >> >>
    >> >> >> >> FilterOperator *foi = new FilterOperator;
    >> >> >> >>
    >> >> >> >> Widget pb = XtVaCreateManagedWidget(
    >> >> >> >> label.c_str(),
    >> >> >> >> xmPushButtonWidgetClass, _operators_pd,
    >> >> >> >> XmNuserData, foi, NULL);
    >> >> >>
    >> >> >> The XmNuserData value that you specify here is a pointer, of type
    >> >> >> "Filter
    >> >> >> Operator *".
    >> >> >> This is OK, since XmNuserData is an XtPointer, and thus can hold
    >> >> >> any
    >> >> >> pointer.
    >> >> >>
    >> >> >> >>
    >> >> >> >> > void FilterWidget::OperatorCB( Widget w, XtPointer d,
    >> >> >> >> > XtPointer
    >> >> >> >> > s )
    >> >> >> >> > {
    >> >> >> >> > FilterOperator fop;
    >> >> >> >> > XtVaGetValues( w, XmNuserData, &fop, 0 );
    >> >> >>
    >> >> >> The above is wrong - you need to pass the address of an XtPointer
    >> >> >> to
    >> >> >> XtVaGetValues
    >> >> >> when retrieving XmNuserData, since you set it equal to a pointer:
    >> >> >>
    >> >> >> XtPointer temp;
    >> >> >> FilterOperator *pfop;
    >> >> >> XtVaGetValues( w, XmNuserData, &temp, NULL );
    >> >> >> pfop = (FilterOperator *)temp;
    >> >> >>
    >> >> >> ... then use pfop as a pointer to a FilterOperator.
    >> >> >>
    >> >> >>
    >> >> >> > Thanks in advance,
    >> >> >> > Mehaboob
    >> >> >> >
    >> >> >> --
    >> >> >> Fred L. Kleinschmidt
    >> >> >> Boeing Associate Technical Fellow
    >> >
    >> > Hi,
    >> >
    >> > Thanks a lot for the reply.
    >> > I tried the below method as mentioned by you to fetch the value.
    >> >
    >> > XtPointer temp;
    >> > FilterOperator *pfop;
    >> > XtVaGetValues( w, XmNuserData, &temp, NULL );
    >> > pfop = (FilterOperator *)temp;
    >> >
    >> > It fetches the value but I have to pass it to another function which
    >> > expects input of type FilterOperator and hence results in compilation
    >> > error.
    >> >
    >> > function:
    >> > ((FilterWidget*)d)->Operator( pfop );
    >> >
    >> > Compliation Error:
    >> > "../src/FilterWidget.cxx", line 582: error #2304: no instance of
    >> > overloaded function "FilterWidget::Operator" matches the argment list
    >> >
    >> > I cannot change the input type as it is used in many places.
    >> > Is it possible to convert pfop as FilterOperator and pass it to
    >> > function.
    >> >
    >> > Mehaboob
    >> >

    >>
    >> Just pass *pfop instead of pfop
    >>
    >> --
    >> Fred L. Kleinschmidt
    >> Boeing Associate Technical Fellow
    >> Technical Architect, Software Reuse Project

    >
    > Thanks a lot for the reply.
    > The reason why I asked about passing FilterOperator to the function is,
    >
    > Previously When I tried
    > ((FilterWidget*)d)->Operator( *pfop );
    >
    > I get memory fault.
    > pfop is 0000000000000005
    > &pfop is 9fffffffffffde10
    > Memory fault
    >
    > and the *pfop is points to the content stored at (0000000000000005)
    >


    You haven't shown where variable "d" comes from. Why is it being cast to a
    FilerWidget pointer?
    Also, if you are using C++ rather than C, you have to be careful about
    callback functions. They must be static methods, not instance methods.
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project



+ Reply to Thread