wxComboBox problem in OSX

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
fcapozzi
In need of some credit
In need of some credit
Posts: 2
Joined: Mon May 18, 2020 10:37 am

wxComboBox problem in OSX

Post by fcapozzi » Mon May 18, 2020 11:01 am

Hello, i found a weird behaviour using a wxComboBox control in OSX Mojave.
WxWidget version is 3.1.3 compiled with Xcode 11.4.1

the combo control is created with

Code: Select all

m_comboBox1 = new wxComboBox( this, wxID_ANY, wxT("No device found"), wxDefaultPosition, wxSize( 180,-1 ), 0, NULL, 0 );
Then in the code i add elements to combo with :

Code: Select all

    m_comboBox1->Append("item 0");
    m_comboBox1->Append("item 1");
    m_comboBox1->Append("item 2");
Combo elements count is correct with n=3

Code: Select all

int n = m_comboBox1->GetCount();
but when selecting the element to be visualised in the combo with

Code: Select all

m_comboBox1->SetSelection(1);
Xcode throws an exception and visualise the exception
Thread 9: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
at the line [m_comboBox selectItemAtIndex: item];

Code: Select all

void wxNSComboBoxControl::SetSelectedItem(int item)
{
    SendEvents(false);

    if ( item != wxNOT_FOUND )
    {
        wxASSERT_MSG( item >= 0 && item < [m_comboBox numberOfItems],
                      "Inavlid item index." );
        [m_comboBox selectItemAtIndex: item];
    }
    else // remove current selection (if we have any)
    {
        const int sel = GetSelectedItem();
        if ( sel != wxNOT_FOUND )
            [m_comboBox deselectItemAtIndex:sel];
    }

    SendEvents(true);
}
The same code works fine in Microsoft Windows using Visual Studio.
May be something is wrong in the OSX implementation

Any hint ?
Tnx, Fabio.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4227
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxComboBox problem in OSX

Post by ONEEYEMAN » Mon May 18, 2020 6:28 pm

Hi,
Can you reproduce it in the widgets sample?
How exactly did you configure wxWidgets?
Can you post the backtrace from the assertion dialog?

Thank you.

fcapozzi
In need of some credit
In need of some credit
Posts: 2
Joined: Mon May 18, 2020 10:37 am

Re: wxComboBox problem in OSX

Post by fcapozzi » Mon May 18, 2020 8:06 pm

Hello for configure xcode for using wxWidget i followed this forum message
viewtopic.php?f=19&t=45837

May be i do not understand well what you mean with "reproduce it in the widgets sample" can you explain ?
Do you refer the combo sample program in the build tree ? wxWidgets-3.1.3/build-cocoa-debug/samples/combo ... if so it works well.

In my code i do not have problem in selecting the combo items in the GUI using the mouse. The problem arise when i attempt to modify
the current selected element from the code itself. On windows the SetSelection simply change the element displayed in the box while in OSX is thrown an exception. It is the same code.

For the backtrace assertion dialog i don't know well how to capture this dialog from Xcode.. will make some experiment.
Tnx for answer. Fabio.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4227
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxComboBox problem in OSX

Post by ONEEYEMAN » Mon May 18, 2020 8:44 pm

Hi,
I was actually referring to the widgets sample found at wxWidgets-3.1.3/build-cocoa-debug/samples/widgets. It has a page for the wxComboBox.
The combo sample you refer to is about wxOwnerDrawnComboBox - that is implemented strictly with wxWidgets.

And I actually asked how did you configure the library itself. Like what was your:

Code: Select all

cd wxWidgets-3.1.3 && mkdir build-cocoa-debug && cd build-cocoa-debug && ../configure
configure line there was.

Now abolut backtrace - when you see the assertion dialog from the Apple just scroll down and copy paste the backtrace in here.

Thank you.

P.S.: BTW, the Mojave is 10.14, right?

Post Reply