Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Possible crash during project close?
oBFusCATed:
I'm trying to implement multple-select-project-close feature, but I've got a pretty strange crash in the CC.
Here is the patch:
--- Code: ---Index: src/sdk/projectmanager.cpp
===================================================================
--- src/sdk/projectmanager.cpp (revision 8644)
+++ src/sdk/projectmanager.cpp (working copy)
@@ -2325,23 +2325,37 @@ void ProjectManager::OnSaveProject(wxCommandEvent& WXUNUSED(event))
void ProjectManager::OnCloseProject(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId sel = GetTreeSelection();
- if (!sel.IsOk())
+ if (m_IsLoadingProject)
+ {
+ wxBell();
return;
+ }
- FileTreeData* ftd = (FileTreeData*)m_pTree->GetItemData(sel);
- cbProject *proj = 0;
- if (ftd)
- proj = ftd->GetProject();
+ wxArrayTreeItemIds selections;
+ int count = m_pTree->GetSelections(selections);
+ if (count == 0)
+ return;
+ std::set<cbProject*> projectsToClose;
- if (proj)
+ for (size_t ii = 0; ii < selections.GetCount(); ++ii)
{
- if (m_IsLoadingProject || proj->GetCurrentlyCompilingTarget())
- wxBell();
- else
- CloseProject(proj);
+ FileTreeData *ftd = reinterpret_cast<FileTreeData*>(m_pTree->GetItemData(selections[ii]));
+ if (ftd->GetKind() != FileTreeData::ftdkProject)
+ continue;
+
+ cbProject *project = ftd->GetProject();
+ if (project)
+ {
+ if (project->GetCurrentlyCompilingTarget())
+ wxBell();
+ else
+ projectsToClose.insert(project);
+ }
}
+ for (std::set<cbProject*>::iterator it = projectsToClose.begin(); it != projectsToClose.end(); ++it)
+ CloseProject(*it);
+
if (m_pProjects->GetCount() > 0 && !m_pActiveProject)
SetProject(m_pProjects->Item(0), false);
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 8644)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -2427,6 +2427,8 @@ void NativeParser::OnParserStart(wxCommandEvent& event)
TRACE(_T("NativeParser::OnParserStart()"));
cbProject* project = static_cast<cbProject*>(event.GetClientData());
+ if (!Manager::Get()->GetProjectManager()->IsProjectStillOpen(project))
+ project = nullptr;
wxString prj = (project ? project->GetTitle() : _T("*NONE*"));
const ParserCommon::ParserState state = static_cast<ParserCommon::ParserState>(event.GetInt());
--- End code ---
The crash I've got was at this line "wxString prj = (project ? project->GetTitle() : _T("*NONE*"));"
I couldn't reproduce the crash unfortunately and I can't get you a backtrace.
Can someone of the CC gurus comment on this crash?
ollydbg:
Apply this patch, and try the CB workspace, and multi-select a lot of cbp, and context menu-> close project..... But no crash here. :)
oBFusCATed:
I suppose the timing is pretty important... :(
MortenMacFly:
--- Quote from: ollydbg on December 03, 2012, 08:54:55 am ---But no crash here. :)
--- End quote ---
Same here: No crash. But I recall I had that seen line in the crash logs already... just a different use case. I just have no idea what could go wrong except that the pointer is not "nulled" correctly. But how (and actually where) would you do that if a project is deleted?
oBFusCATed:
I suppose, I've got the crash by chance and now it won't happen for 1000 tries.
Is there some detection if a project is closed in CC? I see some timers, so if something like this happens:
1. detect if project is valid -> start CC for project on a timer
2. project is closed
3. timer starts executing
I'm sure it will be pretty nasty. I guess, the CC should be stopped and restarted if a project close is detected.
Navigation
[0] Message Index
[#] Next page
Go to full version