mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
notify BoardCanvas when we're closing a game so that it won't try to
use, in callback on UI thread, a dict that may no longer be valid. Theory is this is why I'm seeing odd crashes in the jni.
This commit is contained in:
parent
8976d26f00
commit
66eb96dce2
3 changed files with 16 additions and 4 deletions
|
@ -2095,6 +2095,7 @@ public class BoardActivity extends XWActivity
|
|||
m_jniThread.waitToStop( save );
|
||||
m_jniThread = null;
|
||||
}
|
||||
m_view.stopHandling();
|
||||
|
||||
clearThis();
|
||||
|
||||
|
|
|
@ -165,10 +165,12 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
|
||||
public void setJNIThread( JNIThread jniThread )
|
||||
{
|
||||
if ( ! jniThread.equals( m_jniThread ) ) {
|
||||
DbgUtils.assertOnUIThread();
|
||||
if ( null == jniThread ) {
|
||||
} else if ( ! jniThread.equals( m_jniThread ) ) {
|
||||
DbgUtils.logf( "BoardCanvas changing threads" );
|
||||
m_jniThread = jniThread;
|
||||
}
|
||||
m_jniThread = jniThread;
|
||||
}
|
||||
|
||||
public int getCurPlayer()
|
||||
|
@ -538,9 +540,9 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
|||
m_dictChars = null;
|
||||
m_activity.runOnUiThread( new Runnable() {
|
||||
public void run() {
|
||||
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
||||
// draw again
|
||||
if ( null != m_jniThread ) {
|
||||
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
||||
// draw again
|
||||
m_jniThread.handle( JNIThread.JNICmd
|
||||
.CMD_INVALALL );
|
||||
}
|
||||
|
|
|
@ -269,6 +269,15 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public void stopHandling()
|
||||
{
|
||||
m_jniThread = null;
|
||||
m_jniGamePtr = 0;
|
||||
if ( null != m_canvas ) {
|
||||
m_canvas.setJNIThread( null );
|
||||
}
|
||||
}
|
||||
|
||||
// SyncedDraw interface implementation
|
||||
public void doJNIDraw()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue