wxComboBox - causes a Runtime error R6025

I am getting the Runtime error in some cases and it has something to do
with the code I am calling in EVT_SET_FOCUS.

EVT_SET_FOCUS basically calls a function LoadChoices to load the choices
into the combobox from my database.

EVT_TEXT_ENTER basically updates the database with a new choice entered
by the user or updates an existing one if it got changed by the user and
it done calls the same LoadChoices routine to update the combobox.

I relazied that I would get the runtime error in the EVT_SET_FOCUS event
which occurs just after the EVT_TEXT_ENTER event, so I set myself a flag
that I don't need to call LoadChoices in EVT_SET_FOCUS.

Can someone explain to me what I am doing wrong that I get this R6025
runtime error (pure virtual function call). I tried all kind of combinations but without success.

Thanks in advance.
Werner

Werner F. Bruhin wrote:

I am getting the Runtime error in some cases and it has something to do
with the code I am calling in EVT_SET_FOCUS.

EVT_SET_FOCUS basically calls a function LoadChoices to load the choices
into the combobox from my database.

EVT_TEXT_ENTER basically updates the database with a new choice entered
by the user or updates an existing one if it got changed by the user and
it done calls the same LoadChoices routine to update the combobox.

I relazied that I would get the runtime error in the EVT_SET_FOCUS event
which occurs just after the EVT_TEXT_ENTER event, so I set myself a flag
that I don't need to call LoadChoices in EVT_SET_FOCUS.

Can someone explain to me what I am doing wrong that I get this R6025
runtime error (pure virtual function call). I tried all kind of combinations but without success.

Please create a small sample that shows the problem.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin,

Attached a smallish sample, a bit messy as I just ripped out the db related stuff.

I get the runtime error on this sample by just loading it and closing it, I also get it when I select once or twice from the choices, then enter some stuff into the combobox and press enter.

See you
Werner

Robin Dunn wrote:

ComboBoxProblem.py (5.97 KB)

···

Werner F. Bruhin wrote:

I am getting the Runtime error in some cases and it has something to do
with the code I am calling in EVT_SET_FOCUS.

EVT_SET_FOCUS basically calls a function LoadChoices to load the choices
into the combobox from my database.

EVT_TEXT_ENTER basically updates the database with a new choice entered
by the user or updates an existing one if it got changed by the user and
it done calls the same LoadChoices routine to update the combobox.

I relazied that I would get the runtime error in the EVT_SET_FOCUS event
which occurs just after the EVT_TEXT_ENTER event, so I set myself a flag
that I don't need to call LoadChoices in EVT_SET_FOCUS.

Can someone explain to me what I am doing wrong that I get this R6025
runtime error (pure virtual function call). I tried all kind of combinations but without success.

Please create a small sample that shows the problem.

Werner F. Bruhin wrote:

Robin,

Attached a smallish sample, a bit messy as I just ripped out the db related stuff.

I get the runtime error on this sample by just loading it and closing it, I also get it when I select once or twice from the choices, then enter some stuff into the combobox and press enter.

Change your focus handler to look like this:

     def EvtFocus(self, event):
         if not self.IsBeingDeleted():
             print 'evt focus'
             obj = event.GetEventObject()
             if self.evtCBEdone == True: # this is needed to prevent run time error 6025 in some cases
                 self.evtCBEdone = False
             else:
                 print 'evt focus loadchoices'
                 self.LoadChoices(obj)
             print 'evt focus - at end'
             event.Skip()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin,

Thanks, your solution works greate!

See you
Werner

Robin Dunn wrote:

···

Werner F. Bruhin wrote:

Robin,

Attached a smallish sample, a bit messy as I just ripped out the db related stuff.

I get the runtime error on this sample by just loading it and closing it, I also get it when I select once or twice from the choices, then enter some stuff into the combobox and press enter.

Change your focus handler to look like this:

    def EvtFocus(self, event):
        if not self.IsBeingDeleted():
            print 'evt focus'
            obj = event.GetEventObject()
            if self.evtCBEdone == True: # this is needed to prevent run time error 6025 in some cases
                self.evtCBEdone = False
            else:
                print 'evt focus loadchoices'
                self.LoadChoices(obj)
            print 'evt focus - at end'
            event.Skip()