From 55cb36d091f71ea614f5d2683eff7b143292ff3a Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 16 Aug 2020 19:29:08 -0700 Subject: [PATCH] cleanup --- .../android/xw4/DictBrowseDelegate.java | 35 ------------------- .../org/eehouse/android/xw4/PatTableRow.java | 7 ---- .../src/main/res/menu/dict_browse_menu.xml | 19 +++++----- xwords4/common/dictiter.h | 12 +++---- xwords4/common/dictmgr.c | 2 +- xwords4/common/dictmgr.h | 2 +- xwords4/common/dictnry.c | 2 ++ 7 files changed, 18 insertions(+), 61 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java index 3b36fa0cb..87f83511d 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java @@ -635,41 +635,6 @@ public class DictBrowseDelegate extends DelegateBase return result; } - private void setMinMax( int min, int max ) - { - // I can't make a second call to setListAdapter() work, nor does - // notifyDataSetChanged do anything toward refreshing the - // adapter/making it recognize a changed dataset. So, as a - // workaround, relaunch the activity with different parameters. - // if ( m_browseState.m_minShown != min || - // m_browseState.m_maxShown != max ) { - - // m_browseState.m_pos = 0; - // m_browseState.m_top = 0; - // m_browseState.m_minShown = min; - // m_browseState.m_maxShown = max; - // m_browseState.m_pats = getFindText(); - // DBUtils.dictsSetOffset( m_activity, m_name, m_loc, m_browseState ); - - // setUpSpinners(); - - // initList(); - // } - } - - private void figureMinMax( int[] counts ) - { - Assert.assertTrue( counts.length == XwJNI.MAX_COLS_DICT + 1 ); - m_minAvail = 0; - while ( 0 == counts[m_minAvail] ) { - ++m_minAvail; - } - m_maxAvail = XwJNI.MAX_COLS_DICT; - while ( 0 == counts[m_maxAvail] ) { // - --m_maxAvail; - } - } - private String[] m_nums; private void makeSpinnerAdapter( Spinner spinner, int curVal ) { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java index 58876f72e..4010159cb 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PatTableRow.java @@ -43,16 +43,9 @@ public class PatTableRow extends TableRow { { getFields(); - // PatDesc result = null; String strPat = mEdit.getText().toString(); out.strPat = strPat; out.anyOrderOk = mCheck.isChecked(); - // if ( null != strPat && 0 < strPat.length() ) { - // result = new PatDesc(); - // result.strPat = strPat; - // result.anyOrderOk = mCheck.isChecked(); - // } - // return result; } public void setFromDesc( PatDesc desc ) diff --git a/xwords4/android/app/src/main/res/menu/dict_browse_menu.xml b/xwords4/android/app/src/main/res/menu/dict_browse_menu.xml index 9336bf45d..c6ac05733 100644 --- a/xwords4/android/app/src/main/res/menu/dict_browse_menu.xml +++ b/xwords4/android/app/src/main/res/menu/dict_browse_menu.xml @@ -1,14 +1,13 @@ - - - - + + + diff --git a/xwords4/common/dictiter.h b/xwords4/common/dictiter.h index de28462dd..fe1c2e44f 100644 --- a/xwords4/common/dictiter.h +++ b/xwords4/common/dictiter.h @@ -1,6 +1,6 @@ /* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */ /* - * Copyright 1997 - 2011 by Eric House (xwords@eehouse.org). All rights + * Copyright 1997 - 2020 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -57,19 +57,17 @@ typedef struct DictIter DictIter; * tile sets (e.g. [A.B.C]); also [^A.B.C] means NOT these, and [+A.B.C] means * use at most once [+A.B.C]{3} would mean "use all of them once each" * - * '?' (meaning anything, same as '.' in most regex languages), + * '_' (meaning blank/anything, same as '.' in most regex languages), * * '*' meaning 0 or more of what's before * * '+' meaning 1 or more of what's before * - * '{m[,n]}' meaning between m and n of what's before, so ?{2,15} matches + * '{m[,n]}' meaning between m and n of what's before, so _{2,15} matches * everything * - * '()' also required to express word length: (AB_*CD){2,15} is "an word - * beginning with AB and ending with CD from 2 to 15 letters long. - * - * '^' and '$' matching beginning and end of word (not required, so not yet) + * '()' (not implemented) also required to express word length: (AB_*CD){2,15} + * is "an word beginning with AB and ending with CD from 2 to 15 letters long. */ /* di_makeIter: It's either-or: provide the pattern as a reg-ex string, or as diff --git a/xwords4/common/dictmgr.c b/xwords4/common/dictmgr.c index c2013bbd8..1acbd0aa1 100644 --- a/xwords4/common/dictmgr.c +++ b/xwords4/common/dictmgr.c @@ -101,7 +101,7 @@ dmgr_get( DictMgrCtxt* dmgr, XWEnv xwe, const XP_UCHAR* key ) } void -dmgr_put( DictMgrCtxt* dmgr, XWEnv xwe, const XP_UCHAR* key, DictionaryCtxt* dict ) +dmgr_put( DictMgrCtxt* dmgr, XWEnv xwe, const XP_UCHAR* key, const DictionaryCtxt* dict ) { pthread_mutex_lock( &dmgr->mutex ); diff --git a/xwords4/common/dictmgr.h b/xwords4/common/dictmgr.h index 276625f60..e8a79a04f 100644 --- a/xwords4/common/dictmgr.h +++ b/xwords4/common/dictmgr.h @@ -32,7 +32,7 @@ typedef struct DictMgrCtxt DictMgrCtxt; DictMgrCtxt* dmgr_make( MPFORMAL_NOCOMMA ); void dmgr_destroy( DictMgrCtxt* dmgr, XWEnv xwe ); -void dmgr_put( DictMgrCtxt* dmgr, XWEnv xwe, const XP_UCHAR* key, DictionaryCtxt* dict ); +void dmgr_put( DictMgrCtxt* dmgr, XWEnv xwe, const XP_UCHAR* key, const DictionaryCtxt* dict ); const DictionaryCtxt* dmgr_get( DictMgrCtxt* dmgr, XWEnv xwe, const XP_UCHAR* key ); #ifdef CPLUS diff --git a/xwords4/common/dictnry.c b/xwords4/common/dictnry.c index b3e613304..e7700abeb 100644 --- a/xwords4/common/dictnry.c +++ b/xwords4/common/dictnry.c @@ -80,6 +80,8 @@ p_dict_unref( const DictionaryCtxt* dict, XWEnv xwe #endif pthread_mutex_unlock( &_dict->mutex ); if ( 0 == _dict->refCount ) { + /* There's a race here. If another thread locks the mutex we'll + still destroy the dict (and the locked mutex!!!) PENDING */ pthread_mutex_destroy( &_dict->mutex ); (*dict->destructor)( _dict, xwe ); }