so if its in the wrong place please move it.
Basically what seems to happen is the GUI locks-up while inserting new rows to the database though it should be updating a counter in the status bar...
I believe it seems to lockup when ever there is an event passed through the event table... But I also noticed that it sometimes locks up when minimizing say the task manager or another window. Or if its left alone with no mouse movement after x number of inserts (usually 15 or 200) it locks up. Though it still is inserting new rows.
If code will help here is:
EVT Table
Code: Select all
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(CLIENT_EXIT, MyFrame::OnExit)
EVT_MENU(CLIENT_ABOUT, MyFrame::OnAbout)
EVT_MENU(CLIENT_OPEN, MyFrame::OnOpenConnection)
EVT_MENU(CLIENT_CLOSE, MyFrame::OnCloseConnection)
EVT_MENU(CLIENT_SEND_CMD, MyFrame::OnSendCMD)
EVT_MENU(CLIENT_DB, MyFrame::LoadListToDB)
EVT_TEXT_MAXLEN(CLIENT_TXT_UPDATE, MyFrame::OnTextResize)
EVT_SOCKET(SOCKET_ID, MyFrame::OnSocketEvent)
END_EVENT_TABLE()
Code: Select all
void MyFrame::LoadListToDB(wxCommandEvent& event) {
std::vector <wxString> Failures(2); //Stores Failed Entries
NewsGroup tmpGroup;
wxString gfile = "groupslist.dat";
unsigned int lineCtr = 0;
unsigned int fCount = 0;
unsigned int success = 0;
wxTextFile file(gfile);
if (!file.Exists()) {
m_text->AppendText(_("Group cache list file doesn't exist!\n"));
return;
}
file.Open();
//lineCtr = file.GetLineCount();
wxString s;
s = file.GetFirstLine();
tmpGroup = m_split.SplitString(s);
tmpGroup.id << lineCtr + 1;
if (m_group_db->InsertNewGroup(tmpGroup.id, tmpGroup.GroupName, tmpGroup.lastPost,
tmpGroup.firstPost, tmpGroup.postable)) {
success++;
} else {
if (fCount >= Failures.size()) { Failures.resize(Failures.size()+15); }
Failures[fCount] = s;
fCount++;
}
//While Line != the end of list terminator
m_caching = true;
while (s != "." || s != '\n') {
lineCtr++;
s = file.GetNextLine();
tmpGroup = m_split.SplitString(s);
tmpGroup.id << lineCtr;
if (m_group_db->InsertNewGroup(tmpGroup.id, tmpGroup.GroupName, tmpGroup.lastPost,
tmpGroup.firstPost, tmpGroup.postable)) {
success++;
} else {
//Enlarge Vector elements count
if (fCount >= Failures.size()) { Failures.resize(Failures.size()+15); }
Failures[fCount] = s;
fCount++;
}
UpdateGroupBar(lineCtr); //this is suppose to update part of the status bar in a lazy attempt to prevent the GUI from locking
}
m_caching = false;
unsigned int tally = lineCtr - success;
s << tally << " groups failed to be added to db.\n"
<< success << " groups have been added to db.\n"
<< "Group Failures follow: \n";
for (unsigned int i = 0; i < Failures.size(); i++ ) {
s << Failures[i];
}
m_text->AppendText(_(s));
Failures.resize(1);
}