Skip to content

Commit

Permalink
Fixed a problem where a synchronizion lock was used incorrectly in Wi…
Browse files Browse the repository at this point in the history
…dgetService

Change-Id: I209a13fa999b53872018c82134a32e6ee987e143
  • Loading branch information
Michael Chan committed Dec 13, 2012
1 parent 48bcc4c commit f6bc9bc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/com/android/calendar/widget/CalendarAppWidgetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public static class CalendarFactory extends BroadcastReceiver implements
private Context mContext;
private Resources mResources;
private static CalendarAppWidgetModel mModel;
private static volatile Integer mLock = new Integer(0);
private int mLastLock;
private static Object mLock = new Object();
private static volatile int mSerialNum = 0;
private int mLastSerialNum = -1;
private CursorLoader mLoader;
private final Handler mHandler = new Handler();
private static final AtomicInteger currentVersion = new AtomicInteger(0);
Expand Down Expand Up @@ -154,7 +155,7 @@ public void run() {
mLoader.setUri(uri);
mLoader.setSelection(selection);
synchronized (mLock) {
mLastLock = ++mLock;
mLastSerialNum = ++mSerialNum;
}
mLoader.forceLoad();
}
Expand Down Expand Up @@ -379,7 +380,7 @@ public void initLoader(String selection) {
EVENT_SORT_ORDER);
mLoader.setUpdateThrottle(WIDGET_UPDATE_THROTTLE);
synchronized (mLock) {
mLastLock = ++mLock;
mLastSerialNum = ++mSerialNum;
}
mLoader.registerListener(mAppWidgetId, this);
mLoader.startLoading();
Expand Down Expand Up @@ -484,7 +485,7 @@ public void onLoadComplete(Loader<Cursor> loader, Cursor cursor) {
return;
}

if (mLastLock != mLock) {
if (mLastSerialNum != mSerialNum) {
return;
}

Expand Down

0 comments on commit f6bc9bc

Please sign in to comment.