Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear player's history away from main thread if lock locked #2457

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.fastasyncworldedit.core.util.BrushCache;
import com.fastasyncworldedit.core.util.MainUtil;
import com.fastasyncworldedit.core.util.StringMan;
import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.TextureHolder;
import com.fastasyncworldedit.core.util.TextureUtil;
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
Expand Down Expand Up @@ -405,6 +406,15 @@ public void setTimezone(ZoneId timezone) {
*/
public void clearHistory() {
//FAWE start
if (Fawe.isMainThread() && !historyWriteLock.tryLock()) {
dordsor21 marked this conversation as resolved.
Show resolved Hide resolved
// Do not make main thread wait if we cannot immediately clear history (on player logout usually)
TaskManager.taskManager().async(this::clearHistoryTask);
return;
}
clearHistoryTask();
}

private void clearHistoryTask() {
historyWriteLock.lock();
try {
// Ensure that changesets are properly removed
Expand All @@ -420,8 +430,8 @@ public void clearHistory() {
save();
historySize = 0;
currentWorld = null;
//FAWE end
}
//FAWE end

/**
* Remember an edit session for the undo history. If the history maximum
Expand Down
Loading