Add more debug output, UI thread asserts

This commit is contained in:
MrLetsplay 2024-06-06 21:04:15 +02:00
parent 09d7d80d29
commit ed7e89d1ab
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
4 changed files with 17 additions and 2 deletions

View File

@ -393,6 +393,12 @@ public class ShareClient extends AbstractUIPlugin implements MessageListener, Di
return partListener;
}
public static void assertOnUIThread() {
if(!Thread.currentThread().equals(Display.getDefault().getThread())) {
MessageDialog.openError(null, "Assertion failed", "Not on UI thread");
}
}
@Override
public void earlyStartup() {
}

View File

@ -89,7 +89,8 @@ public class ShareSession {
@Override
public void onInsert(int index, byte character) {
// TODO: assert that we are on the UI thread
ShareClient.assertOnUIThread();
ShareClientDocumentListener documentListener = ShareClient.getDefault().getPartListener().getListener(path);
if(documentListener != null) {
IDocument document = documentListener.getDocument();
@ -108,7 +109,8 @@ public class ShareSession {
@Override
public void onDelete(int index) {
// TODO: assert that we are on the UI thread
ShareClient.assertOnUIThread();
ShareClientDocumentListener documentListener = ShareClient.getDefault().getPartListener().getListener(path);
if(documentListener != null) {
IDocument document = documentListener.getDocument();

View File

@ -35,6 +35,8 @@ public class ShareClientDocumentListener implements IDocumentListener {
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
ShareClient.assertOnUIThread();
if(ignoreChanges) return;
System.out.println("UPDATE ON THREAD " + Thread.currentThread());

View File

@ -178,6 +178,11 @@ public class ShareView extends ViewPart {
sb.append("--- Document: ").append(path).append('\n');
sb.append(document.getContentsAsString());
sb.append('\n');
for(int i = 0; i < document.getCharBag().size(); i++) {
sb.append(document.getCharBag().get(i)).append('\n');
}
sb.append('\n');
sb.append('\n');