Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 23rd, 2007, 11:39 AM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
More Mac Issues - wxPython

Has Anyone Tried wxPython For Max OSX?

I'm running Python 2.5 on Mac OSX 10.3.9.

I downloaded wxPython 2.8 - OSX - Unicode - 2.8.6.1 - Universal - Python 2.5.

When I run it, everything works fine. I can do lots of things like disable/enable widgets, select from a combo box, hide the window, select from the file menu, etc, etc...

However, when I try this code, I get a "Segmentation Fault" or "Bus Error". This does not happen on Windows. Any idea what's going on?

    def findBallot(self, event):
        self.checkBallotEntry(event)

        # Initiate Search List
        if self.lastImage == self.invalidImage:

            searchFor = event.GetString()
            matches = findClosest(searchFor, self.handler.ballotSeen)

            if matches:

                # hide stuff underneath
                self.ballotType.Hide()
                self.outputFile.Hide()
                self.selectFile.Hide()

                # remove the old search box
                if self.searchResults:
                    self.searchResults.Destroy()
                    self.searchResults = None

                matches.sort()
                # show the new search box
                self.searchResults = wx.ListBox(self.generalPanel, id=lazyID('search'), pos=wx.Point(75, 64), size=wx.Size(167, 75),
                    choices=[__LANG_SEARCH_RESULTS__%len(matches)] + matches, style=wx.LB_SINGLE)
                self.Bind(wx.EVT_LISTBOX, self.selectSearch, self.searchResults)

    def destroySearch(self):
        self.searchResults.Destroy()
        self.searchResults = None

        self.ballotType.Show()     
        self.outputFile.Show()
        self.selectFile.Show()

    def selectSearch(self, event):
        if event.GetSelection() != 0: # Can't pick the first result
            searchChoice = event.GetString()
            self.ballotList.SetValue(searchChoice)
            self.ballotList.SetFocusFromKbd()
            self.ballotList.SetInsertionPointEnd()
            
            # End Search List
            if self.searchResults:
                self.destroySearch()
            
            self.checkBallotEntry(None)

"findBallot" is called when a letter is typed. It toggles a search list if the entry is incorrect.

"destroySearch" destroys this search list once the entry is correct, or an item has been selected.

"selectSearch" is called when the user selects one of the search options.

The error happens after "selectSearch" is done. This makes little sense, because after "selectSearch" is done, no code is executed. The window remains idle, as a solitary cron task continues running every second afterwards. This task has always been executing, so this shouldn't be an issue. Nevertheless, the code is:

    def handleGlitch(self, event):
        # The win32api doesn't always tell us when the combobox's text changes, so check every second in case
        self.checkBallotEntry(None)
        event.Skip()

But "self.checkBallotEntry(None)" can't be the problem either, because it was succesfully called near the end of "selectSearch", which finished executing before the error occurred.

I can't show you any more code then this. I actually signed a non-disclosure agreement that stops me from even giving that much away... but whatever...

Edit : Probably important to note. I can still see the search list before the program stalls and crashes. This means it did not destroy the search list when it was supposed to. I think this is a good indicator of the error. What am I doing then that Mac OSX doesn't like? It was fine hiding/enabling other widgets. Maybe I'll look at the "destroy" attribute under Mac OSX. Do some testing there...
Sane is offline   Reply With Quote
Old Nov 23rd, 2007, 11:49 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: More Mac Issues - wxPython

I don't know anything about the Mac, but I'll make a couple of observations. Generally, a segmentation fault means that memory has been accessed when it is not valid to access that area of memory, for whatever reason.

A bus fault indicates that memory was accessed that can't be accessed. Usually, this is because the physical implementation of the memory is such that it can't be addressed on any given byte boundary, but must be accessed on, for example, 4-byte boundaries.

Maybe that will give you a clue. It certainly introduces platform dependencies that might result in a bug.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 23rd, 2007, 12:01 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: More Mac Issues - wxPython

This problem is starting to look more defined now. Thanks.

I'm thinking it doesn't like me switching "self.searchResults" back and forth between a wxWidget listbox and a "None" type object, and then finally destroying it. It's most likely having memory allocation trouble with that. I will tweak the implementation, and see if that helps.
Sane is offline   Reply With Quote
Old Nov 23rd, 2007, 12:16 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: More Mac Issues - wxPython

Yes! It works. Thanks, that was the exact issue. I made it create the listbox once, and toggle it on/off instead. It's actually better this way. Come to think of it, it's quite stupid to keep destroying/initiating the widget, especially when there's no good reason to... An obvious memory hazard.

Adios.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Intermittent issues blud Community Announcements and Feedback 3 Nov 2nd, 2007 8:46 AM
Can Mac be run... mattireland Coder's Corner Lounge 11 Aug 16th, 2007 4:13 PM
Table issues... Glastea HTML / XHTML / CSS 2 Jan 12th, 2007 1:54 AM
Glade and wxPython? titaniumdecoy Python 7 Jul 2nd, 2006 9:54 PM
wxPython Help Sane Python 25 Jun 2nd, 2006 5:57 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:03 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC