Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
unknown exception
280Z28:
Oh yeah, you have to change wxChar* back to char* in wxCrc32::FromString()
That's all I had to do to 1536+your patch to make it build.
grv575:
Perfect. works. build 1524 tested. Do note that the generated default.conf file will crash prior versions now :)
But just make a note of it in the wiki - delete default.conf if you get an undefined exception.
grv575:
One thing. This gives a crc of 0:
--- Code: ---unsigned long wxCrc32::FromString(const wxString& text)
{
static unsigned long *crc_table = NULL;
unsigned long crc = 0;
const char* p = text.mb_str(wxConvUTF8);
if (text)
{
// Get the crc table, on first call, generate, otherwise do nothing
crc_table = GetCRC32Table( crc_table ) ;
// Do we have a crc table?
if ( crc_table )
{
// Calculate the checksum
crc = 0xFFFFFFFFUL;
while (*p)
{ crc = (crc>>8) ^ crc_table[ (crc^(*p++)) & 0xFF ]; }
crc ^= 0xFFFFFFFFUL ;
}
}
// If we have a crc table, delete it from memory
if ( crc_table ) { delete[] crc_table; }
// Set it to a null pointer, the have it (re)created on next calls to this
// function
crc_table = NULL;
// Return the checksum result
return( crc ) ;
}
--- End code ---
This computes the correct crc (verified same as 1512 binary):
--- Code: ---unsigned long wxCrc32::FromString(const wxString& text)
{
static unsigned long *crc_table = NULL;
unsigned long crc = 0;
int i = 0;
if (text)
{
// Get the crc table, on first call, generate, otherwise do nothing
crc_table = GetCRC32Table( crc_table ) ;
// Do we have a crc table?
if ( crc_table )
{
// Calculate the checksum
crc = 0xFFFFFFFFUL;
while (text[i])
{ crc = (crc>>8) ^ crc_table[ (crc^(text[i++])) & 0xFF ]; }
crc ^= 0xFFFFFFFFUL ;
}
}
// If we have a crc table, delete it from memory
if ( crc_table ) { delete[] crc_table; }
// Set it to a null pointer, the have it (re)created on next calls to this
// function
crc_table = NULL;
// Return the checksum result
return( crc ) ;
}
--- End code ---
Should the latter be used? I think it's something about the conversion in unicode or ???
280Z28:
crc is a binary data check, I have no idea why it's taking variable length srings at all. It should take a void* and size_t and cast it to unsigned char :?
--- Code: ---unsigned int wxCrc32::FromString(const wxString& text)
{
const char* p = text.mb_str(wxConvUTF8);
return FromBytes(p, strlen(p));
}
unsigned int wxCrc32::FromBytes(const void* data, size_t length)
{
static unsigned int *crc_table = NULL;
unsigned int crc = 0;
const unsigned char* p = static_cast<const unsigned char*>(data);
if (p)
{
// Get the crc table, on first call, generate, otherwise do nothing
crc_table = GetCRC32Table( crc_table );
// Do we have a crc table?
if ( crc_table )
{
// Calculate the checksum
crc = 0xFFFFFFFFUL;
while (length--)
{ crc = (crc>>8) ^ crc_table[ (crc^(*p++)) & 0xFF ]; }
crc ^= 0xFFFFFFFFUL ;
}
}
// If we have a crc table, delete it from memory
if ( crc_table ) { delete[] crc_table; }
// Set it to a null pointer, the have it (re)created on next calls to this
// function
crc_table = NULL;
// Return the checksum result
return( crc ) ;
}
--- End code ---
280Z28:
I set those back to #defines in appglobals.h, and made the change above to the crc check, and now it saves the CRC and looks like this. :)
[attachment deleted by admin]
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version