Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
unknown exception
grv575:
ahh... uncheck return value:
main.cpp:800 (LoadWindowState())
--- Code: --- buf = Manager::Get()->GetConfigManager(_T("app"))->ReadBinary(_T("/main_frame/layout")); <-------
wxMemoryInputStream ms(buf.c_str(), buf.Length());
pLayoutManager->LoadFromStream( ms );
pSlideBar->LoadFromStream( ms );
--- End code ---
and configmanager.cpp:920
--- Code: --- if(bin->QueryIntAttribute("crc", (int*)&crc) != TIXML_SUCCESS)
return wxEmptyString;
--- End code ---
So in main.cpp, buf gets set to the wxEmptyString returned by ReadBinary(), and then we don't guard the
--- Code: --- wxMemoryInputStream ms(buf.c_str(), buf.Length());
pLayoutManager->LoadFromStream( ms );
pSlideBar->LoadFromStream( ms );
--- End code ---
code for the case when buf == wxEmptystring.
rickg22:
I see. So we have 2 tasks:
1) Take into account the "zero" CRC special case (it CAN happen, you know). Can you do this, grv?
2) Fix the bug that makes the CRC get miscalculated in the first place. <- This is going to get tricky.
thomas:
--- Quote from: grv575 on December 16, 2005, 08:09:16 pm ---...
--- End quote ---
Grv575, the problem is that LoadWindowState does not check the return value it gets from ConfigManager.
The CRC is calculated over the binary layout data which is saved. This is actually meant to prevent crashes (yes I know, that's ironic). The background of this is that people are editing the config file in a text editor. I don't like it, but there's nothing you can do against that. The CRC is meant to prevent accidential changes to binary data (which will be detrimental in most cases and very hard to see).
So when ConfigManger saves and restores binary data, it calculates the CRC, and if the checksum does not match, it returns wxEmptyString. Now there are two problems:
1. the CRC is not correct due to some bug which only happens in Unicode
2. LoadWindowState does not care and just hands wxEmptyString over to wxDockit.
Solution: the CRC calculation must be fixed (and, there should be a check against wxEmptyString). Unluckily, I do not know what is wrong in the CRC calculation.
About the xml tags... No, the parser is not broken. You are right, LAYOUT and layout are two completely different things, this is intentional :)
thomas:
--- Quote from: rickg22 on December 16, 2005, 08:47:28 pm ---1) Take into account the "zero" CRC special case (it CAN happen, you know). Can you do this, grv?
--- End quote ---
No...! CRC == 0 is perfectly valid.
What ConfigManager does is it compares the stored CRC with the freshly calculated one. These two must be the same, whether they are zero or any other number does not matter. They just have to be correct :)
grv575:
Tracing further, the calced and stored crcs DO match. This is not the problem. The problem lies in
sdk\base64.cpp:wxBase64::Decode()
it takes a wxString (and not a buffer??? isn't this wrong since a 0 is valid in a byte buffer but not in a string....) and returns a wxString.
Set a breakpoint in the function. You will see it correctly gets passed the <bin></bin> text value:
--- Code: ---FQAAAHd4RG9ja2luZy1TdHJlYW...
--- End code ---
However the base64 decode algorithm builds up a return string starting with ' ', followed by 0x0, etc. This is not OK for a string value. i.e. The returned string is 0x15,0x0, "wxDocking-Stream-v1.0"
See:
http://chxo.com/scripts/base64.php
To decode the string yourself and then click view source on your web browser....you'll see it starts off with binary non-string values.
[attachment deleted by admin]
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version