Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Problems with FilesGroupsAndMasks::Save
Der Meister:
I'm using Code::Blocks Version 1.0 revision 1595 (gcc 3.4.4 Linux/unicode, build: Dec 26 2005 17:16:07).
In the function FilesGroupsAndMasks::Save the each file-group and its mask are stored in that way:
--- Code: --- FileGroups* fg = m_Groups[i];
wxString key;
key << _("/file_groups/group") << i << _T("/") << _T("name");
conf->Write(key, fg->groupName);
key.Clear();
key << _("/file_groups/group") << i << _T("/") << _T("mask");
conf->Write(key, GetStringFromArray(fg->fileMasks, _T(";")));
--- End code ---
Although this looks correct it doesn't work (at least for me). The keys look like this for all entries:
--- Code: ---/file_groups/group/name
/file_groups/group/mask
--- End code ---
You see, the indices are missing although they are pushed into the stream. I have no idea why this happens. I don't think that my wxGTK-installation is broken because similar code works well in other projects and probably in Code::Blocks, too. Is anyone able to re-produce this problem?
Anyway, the result of this problem is that only the last file mask is stored in the config file and thus after re-loading Code::Blocks all files are either added to the group "Ressources" (which seems to be the group with the highest index) or to the group "Others" if the mask for ressources doesn't apply to them.
thomas:
That's a known problem which we have everywhere.
I don't know the cause, but wxString::operator<< fails miserably in Unicode. Using Format() or Printf() solves the problem. We'll have to spend a few days any time soon locating all instances of operator<<.
Der Meister:
Oh... sorry, seems as I missed this thread.
Anyway, 280Z28's solution with wxString::Printf seems to work. It looks like this now:
--- Code: --- FileGroups* fg = m_Groups[i];
wxString key;
key.Printf(_T("/file_groups/group%d/name"), i);
conf->Write(key, fg->groupName);
key.Clear();
key.Printf(_T("/file_groups/group%d/mask"), i);
conf->Write(key, GetStringFromArray(fg->fileMasks, _T(";")));
--- End code ---
grv575:
--- Quote from: thomas on December 26, 2005, 07:00:46 pm ---That's a known problem which we have everywhere.
I don't know the cause, but wxString::operator<< fails miserably in Unicode. Using Format() or Printf() solves the problem. We'll have to spend a few days any time soon locating all instances of operator<<.
--- End quote ---
This help? Wide I/O streams:
http://www.codeproject.com/vcpp/stl/upgradingstlappstounicode.asp
Der Meister:
I'm not sure if this really would help because as far as I know this is not a general unicode problem but a Code::Blocks specific problem. wxString::operator <<(int) *does* work, even with unicode. Take a look at this example:
--- Code: ---#include <wx/wx.h>
int main()
{
wxString foo;
for (int i = 0; i < 5; ++i)
{
foo << _("/file_groups/group") << i << _("/") << _("name");
wxLogError(foo);
foo.clear();
}
}
--- End code ---
And here is the output of wx-config:
--- Code: ---$ wx-config-2.6 --libs
-pthread -lwx_gtk2u_xrc-2.6 -lwx_gtk2u_html-2.6 -lwx_gtk2u_adv-2.6 -lwx_gtk2u_core-2.6 -lwx_baseu_xml-2.6 -lwx_baseu_net-2.6 -lwx_baseu-2.6
--- End code ---
You can see I really do use unicode and not ANSI.
The output of this sample is what a normal person would expect form the source code:
--- Code: ---23:35:32: Error: /file_groups/group0/name
23:35:32: Error: /file_groups/group1/name
23:35:32: Error: /file_groups/group2/name
23:35:32: Error: /file_groups/group3/name
23:35:32: Error: /file_groups/group4/name
--- End code ---
You see, it works.
But the corresponding source code *in* Code::Blocks (i. e. FilesGroupsAndMasks::Save) doesn't work as it should. It simply drops the index. Thus I think that it *must* be a problem of Code::Blocks and not a general unicode problem. But I have absolutely no idea where the problem really is.
Navigation
[0] Message Index
[#] Next page
Go to full version