Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 936213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:16:42+00:00 2026-05-15T21:16:42+00:00

Hooooookay so here’s another I just have no idea what’s going on problem: The

  • 0

Hooooookay so here’s another “I just have no idea what’s going on” problem:

The first time I make a call to getFullWL() below, I get all my values as expected. Each subsequent call, however, returns nan instead of the true value(-nan(0x400000000) in XCode or something)

Furthermore, if I put my “debug” lines in SFLog the value prints as nan but returns the correct value! If I comment out SFLog (which is just a #define for NSLog depending on a level I set – nothing special), then the value is not caught by isnan() in View but is checked as isnan() in Window

Window and View are sitting on one thread, while DataModule and DCMPix are sitting on another (main thread, I believe). DCMPix also gets some data from a Core-Data object (fImage I believe).

void Window::PopUp()
{
    // Grab the View from the Pipe Thread and cast it to my local namespace subclass View
    View *view = static_cast< View* >(getPipe()->getView(event.context.view));

    float fullww = view->getFullWW();
    float fullwl = view->getFullWL();
    //SFLog(@"WindowLevel Window %f", wl);

    // set SLider Values
    if (!isnan(fullwl)){
        [[vc winLevel] setMinValue:fullwl];
        [[vc winLevel] setMaxValue:(-1.0f*fullwl)];
    }
}


float View::getFullWL()
{
    float wl = _callPixMethod(@selector(fullwl)).floatValue;
    if ( isnan(wl) ) wl = _wl * 2.0f; //<-- is never detected as NaN here
    //SFLog(@"WindowLevel View %f", wl);  //<-- but is *printed* as NaN here
    return wl;
}

// A Union to "cast" the return from the [object performSelector:] method.
//   Since it returns `id` and (float)(id) doesn't work.
union performReturn {
    id OBJC_ID;
    int intValue;
    float floatValue;
    bool boolValue;
};


performReturn View::_callPixMethod(SEL method)
{
    DataModule* data;
    DataVisitor getdata(&data);
    getConfig()->accept(getdata);
    performReturn retVal;
    retVal.OBJC_ID = data->callPixMethod(_datasetIndex, _datasetID, method);
    return retVal;
}


id DataModule::callPixMethod(int index, std::string predicate, SEL method)
{
    DCMPix *pix =[[getSeriesData(predicate) pixList_] objectAtIndex:index];

    pthread_mutex_lock(&_mutex);

    id retVal = [pix performSelector:method];

    pthread_mutex_unlock(&_mutex);

    return retVal;
}

// DCMPix.m (from API, can't change)
- (float) fullwl
{
 if( fullww == 0 && fullwl == 0) [self computePixMinPixMax];
 return fullwl;
}

- (void)computePixMinPixMax
{
    float pixmin, pixmax;

    if( fImage == nil || width * height <= 0) return;

    [checking lock];

    @try 
    {
        if( isRGB)
        {
            pixmax = 255;
            pixmin = 0;
        }
        else
        {
            float fmin, fmax;

            vDSP_minv ( fImage,  1, &fmin, width * height);
            vDSP_maxv ( fImage , 1, &fmax, width * height);

            pixmax = fmax;
            pixmin = fmin;

            if( pixmin == pixmax)
            {
                pixmax = pixmin + 20;
            }
        }

        fullwl = pixmin + (pixmax - pixmin)/2;
        fullww = (pixmax - pixmin);
    }
    @catch (NSException * e) 
    {
        NSLog( @"***** exception in %s: %@", __PRETTY_FUNCTION__, e);
    }

    [checking unlock];
}

Help! Why would I not be getting the correct value in Window?

I also get no nan‘s when calling view->getFullWW() even though it follows the same execution path. (but calls @selector(fullww))

No Errors or exceptions are thrown. Just that bizarre behavior.

Thanks!


After further testing, the following change makes all the difference:

float View::getFullWL()
{
    float wl = _callPixMethod(@selector(fullwl)).floatValue;
    if ( isnan(wl) ) wl = _wl * 2.0f; //<-- is never detected as NaN here
    NSLog(@"WindowLevel View %f", wl);  //<-- is *printed* as NaN here
    return wl; //<-- returns expected value
}

float View::getFullWL()
{
    float wl = _callPixMethod(@selector(fullwl)).floatValue;
    if ( isnan(wl) ) wl = _wl * 2.0f; //<-- is never detected as NaN here
    return wl; //<-- returns `nan`
}

After more testing, it doesn’t matter where I put the NSLog() statement, if it occurs before float fullwl = is assigned.

void Window::PopUp()
{
    // Grab the View from the Pipe Thread and cast it to my local namespace subclass View
    View *view = static_cast< View* >(getPipe()->getView(event.context.view));

    float fullww = view->getFullWW();
    NSLog("Putting this here, makes fullwl work.  Removing it, stores fullwl as nan");
    float fullwl = view->getFullWL();
    //SFLog(@"WindowLevel Window %f", wl);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:16:43+00:00Added an answer on May 15, 2026 at 9:16 pm

    Whelp, Here I am answering my own question again but the answer is… RTFM.

    The aSelector argument should identify a method that takes no arguments. For methods that return anything other than an object, use NSInvocation.

    So the answer is, use NSInvocation and not [obj performSelector:]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.