mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-02 05:03:36 +02:00
Fixed 254888. Fixed rare-case scenario where NPE results in CDebugTarget handling a thread suspended event. Also adjusted code to not assume that a CThread has a non-null ICDIThread reference (used to be the case, but no longer true with introduction of ICDIDisposable support). Finally, removed redundancy in findThread methods.
This commit is contained in:
parent
172288ff75
commit
df7a539470
1 changed files with 23 additions and 14 deletions
|
@ -1275,11 +1275,25 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
|
|
||||||
private void handleThreadTerminatedEvent( ICDIDestroyedEvent event ) {
|
private void handleThreadTerminatedEvent( ICDIDestroyedEvent event ) {
|
||||||
ICDIThread cdiThread = (ICDIThread)event.getSource();
|
ICDIThread cdiThread = (ICDIThread)event.getSource();
|
||||||
CThread thread = findThread( cdiThread );
|
List threads = getThreadList();
|
||||||
if ( thread != null ) {
|
List<CThread> threadsToRemove = new ArrayList<CThread>(1);
|
||||||
getThreadList().remove( thread );
|
for(int i = 0; i < threads.size(); i++) {
|
||||||
thread.terminated();
|
CThread cthread = (CThread)threads.get(i);
|
||||||
thread.fireTerminateEvent();
|
// It's possible CThread has handled the thread-terminated event
|
||||||
|
// before us (by appearing first in the EventManager)
|
||||||
|
// and has disassociated itself from the ICDIThread.
|
||||||
|
// So handle any disassociated CThreads we find. Chances are
|
||||||
|
// there's only one and it's the one we got the terminated event
|
||||||
|
// for. See bugzilla 254888.
|
||||||
|
ICDIThread cdithread = cthread.getCDIThread();
|
||||||
|
if (cdithread == null || cdithread.equals(cdiThread)) {
|
||||||
|
threadsToRemove.add(cthread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (CThread cthread : threadsToRemove) {
|
||||||
|
threads.remove(cthread);
|
||||||
|
cthread.terminated();
|
||||||
|
cthread.fireTerminateEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,19 +1304,14 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
* @return the associated model thread
|
* @return the associated model thread
|
||||||
*/
|
*/
|
||||||
public CThread findThread( ICDIThread cdiThread ) {
|
public CThread findThread( ICDIThread cdiThread ) {
|
||||||
List threads = getThreadList();
|
return findThread(getThreadList(), cdiThread);
|
||||||
for( int i = 0; i < threads.size(); i++ ) {
|
|
||||||
CThread t = (CThread)threads.get( i );
|
|
||||||
if ( t.getCDIThread().equals( cdiThread ) )
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CThread findThread( List threads, ICDIThread cdiThread ) {
|
public CThread findThread( List threads, ICDIThread cdiThread ) {
|
||||||
for( int i = 0; i < threads.size(); i++ ) {
|
for( int i = 0; i < threads.size(); i++ ) {
|
||||||
CThread t = (CThread)threads.get( i );
|
CThread t = (CThread)threads.get( i );
|
||||||
if ( t.getCDIThread().equals( cdiThread ) )
|
ICDIThread thisCdiThread = t.getCDIThread();
|
||||||
|
if ( thisCdiThread != null && thisCdiThread.equals( cdiThread ) )
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue