mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
Fix board not drawing after chat dismissed
A race condition meant the dict chars never got set, which meant no drawing.
This commit is contained in:
parent
2cd94671fd
commit
3f78263f54
1 changed files with 27 additions and 10 deletions
|
@ -184,10 +184,12 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
{
|
{
|
||||||
DbgUtils.assertOnUIThread();
|
DbgUtils.assertOnUIThread();
|
||||||
if ( null == jniThread ) {
|
if ( null == jniThread ) {
|
||||||
|
// do nothing
|
||||||
} else if ( ! jniThread.equals( m_jniThread ) ) {
|
} else if ( ! jniThread.equals( m_jniThread ) ) {
|
||||||
Log.w( TAG, "changing threads" );
|
Log.w( TAG, "changing threads" );
|
||||||
}
|
}
|
||||||
m_jniThread = jniThread;
|
m_jniThread = jniThread;
|
||||||
|
updateDictChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurPlayer()
|
public int getCurPlayer()
|
||||||
|
@ -567,6 +569,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
public void dictChanged( final long newPtr )
|
public void dictChanged( final long newPtr )
|
||||||
{
|
{
|
||||||
long curPtr = m_dict.getDictPtr();
|
long curPtr = m_dict.getDictPtr();
|
||||||
|
boolean doPost = false;
|
||||||
if ( curPtr != newPtr ) {
|
if ( curPtr != newPtr ) {
|
||||||
if ( 0 == newPtr ) {
|
if ( 0 == newPtr ) {
|
||||||
m_fontDims = null;
|
m_fontDims = null;
|
||||||
|
@ -575,20 +578,34 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
|| !XwJNI.dict_tilesAreSame( curPtr, newPtr ) ) {
|
|| !XwJNI.dict_tilesAreSame( curPtr, newPtr ) ) {
|
||||||
m_fontDims = null;
|
m_fontDims = null;
|
||||||
m_dictChars = null;
|
m_dictChars = null;
|
||||||
m_activity.runOnUiThread( new Runnable() {
|
doPost = true;
|
||||||
public void run() {
|
|
||||||
if ( null != m_jniThread ) {
|
|
||||||
m_dictChars = XwJNI.dict_getChars( newPtr );
|
|
||||||
// draw again
|
|
||||||
m_jniThread.handle( JNIThread.JNICmd
|
|
||||||
.CMD_INVALALL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
m_dict.release();
|
m_dict.release();
|
||||||
m_dict = new DictWrapper( newPtr );
|
m_dict = new DictWrapper( newPtr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're on the UI thread this is run inline, so make sure it's
|
||||||
|
// after m_dict is set above.
|
||||||
|
if ( doPost ) {
|
||||||
|
m_activity.runOnUiThread( new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
updateDictChars();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDictChars()
|
||||||
|
{
|
||||||
|
if ( null == m_jniThread ) {
|
||||||
|
// Log.d( TAG, "updateDictChars(): m_jniThread still null!!" );
|
||||||
|
} else if ( null == m_dict ) {
|
||||||
|
// Log.d( TAG, "updateDictChars(): m_dict still null!!" );
|
||||||
|
} else {
|
||||||
|
m_dictChars = XwJNI.dict_getChars( m_dict.getDictPtr() );
|
||||||
|
// draw again
|
||||||
|
m_jniThread.handle( JNIThread.JNICmd.CMD_INVALALL );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Method sSaveMethod;
|
private static Method sSaveMethod;
|
||||||
|
|
Loading…
Reference in a new issue