Thread: Further Mac woes

Further Mac woes

From
Adam H.Pendleton
Date:
Okay, from my last post you can see that pgAdmin3 isn't doing a good
job of selecting my default language.  Now, when I continue after the
assert dialog, the program crashes with this backtrace:

#0  0x90006e40 in strlen ()
#1  0x1286296c in wxMacStringToPascal(wxString const&, unsigned char*)
(from=@0xbffff240, to=0xbffff124 "\022\177= ") at
.../src/mac/carbon/utils.cpp:692
#2  0x0e813644 in wxNotebook::MacSetupTabs() (this=0x1f6db6a0) at
.../src/mac/carbon/notebmac.cpp:372
#3  0x0e8133d8 in wxNotebook::InsertPage(unsigned long, wxWindow*,
wxString const&, bool, int) (this=0x1f6db6a0, nPage=0,
pPage=0x1f6dc570, strText=@0xbffff460, bSelect=false, imageId=-1) at
.../src/mac/carbon/notebmac.cpp:317
#4  0x0e992f44 in wxBookCtrl::AddPage(wxWindow*, wxString const&, bool,
int) (this=0x1f6db6a0, page=0x1f6dc570, text=@0xbffff460,
bSelect=false, imageId=-1) at ../include/wx/bookctrl.h:146
#5  0x17f719f0 in frmMain::frmMain(wxString const&) (this=0x2816000,
title=@0xbffff920) at
/Users/fmonkey/Projects/pgadmin3/src/ui/frmMain.cpp:287
#6  0x17f6dfcc in frmMain::frmMain(wxString const&) (this=0x2816000,
title=@0xbffff920) at
/Users/fmonkey/Projects/pgadmin3/src/ui/frmMain.cpp:113
#7  0x13990dcc in pgAdmin3::OnInit() (this=0x111ad40) at
/Users/fmonkey/Projects/pgadmin3/src/pgAdmin3.cpp:488
#8  0x13996e84 in wxAppConsole::CallOnInit() (this=0x111ad40) at
.../../wx2/include/wx-2.5/wx/app.h:87
#9  0x12816ac4 in wxEntry(int&, wchar_t**) (argc=@0xbffffbf8,
argv=0x111aa00) at ../src/common/init.cpp:394
#10 0x12816c2c in wxEntry(int&, char**) (argc=@0xbffffbf8,
argv=0xbffffc88) at ../src/common/init.cpp:457
#11 0x1398fc04 in main (argc=1, argv=0xbffffc88) at
/Users/fmonkey/Projects/pgadmin3/src/pgAdmin3.cpp:96

#1, wxMacStringToPascal is below:

void wxMacStringToPascal( const wxString&from , StringPtr to )
{
     wxCharBuffer buf = from.mb_str( wxConvLocal ) ;
     int len = strlen(buf) ;

     if ( len > 255 )
         len = 255 ;
     to[0] = len ;
     memcpy( (char*) &to[1] , buf , len ) ;
}

The program crashes on the "int len = strlen(buf)" because buf = NULL
before that call, which means the conversion to a c-string fails in the
previous line, which I think might have something to do with language,
since it appears that "from" is properly defined when the function is
called (can't tell for sure since wxStrings don't really show well in a
debugger).  Any ideas?

ahp


Re: Further Mac woes

From
Andreas Pflug
Date:
Adam H.Pendleton wrote:
>
> The program crashes on the "int len = strlen(buf)" because buf = NULL

This is evel.
wxString.mb_str has nothing to do with languages. It converts a UCS2 or
UCS4 string, i.e. the one-word-per-character (16 or 32 bit) Unicode
representation (Linux/GTK is 32 bit, OSX probably too?) to UTF-8, the
multi byte encoding. It may never crash because it's a simple
algorithmic translation.

Can you step into mb_str?

You can check if from is correct, dump the memory of from.m_pchData
which is an array of wxChars. it should contain one character in each
low byte e.g. 00000050 00000072 0000006f 00000070 which equals Prop


Regards,
Andreas