Skip to content

Commit 0266872

Browse files
committed
Fix threading of project size calculation. Fix issue with reading syllabification information for compound-phone diphthongs.
1 parent 03ca365 commit 0266872

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

app/src/main/java/ca/phon/app/project/RecentProjectsList.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import ca.phon.ui.action.*;
3333
import ca.phon.util.*;
3434
import ca.phon.util.icons.*;
35+
import ca.phon.worker.PhonWorker;
3536

3637
public class RecentProjectsList extends JPanel {
3738

@@ -82,13 +83,18 @@ public void mouseClicked(MouseEvent me) {
8283
public void updateProjectList() {
8384
buttonPanel.removeAll();
8485
buttonPanel.revalidate();
86+
87+
PhonWorker worker = PhonWorker.createWorker();
88+
worker.setFinishWhenQueueEmpty(true);
8589

8690
final RecentProjects history = new RecentProjects();
8791

8892
boolean stripeRow = false;
8993
for(File projectFolder:history) {
9094
final LocalProjectButton projectButton = getProjectButton(projectFolder);
91-
95+
96+
projectButton.updateProjectSize(worker);
97+
9298
if(stripeRow) {
9399
projectButton.setBackground(PhonGuiConstants.PHON_UI_STRIP_COLOR);
94100
stripeRow = false;
@@ -99,6 +105,7 @@ public void updateProjectList() {
99105

100106
buttonPanel.add(projectButton);
101107
}
108+
worker.start();
102109
}
103110

104111
private LocalProjectButton getProjectButton(File projectFolder) {

app/src/main/java/ca/phon/app/welcome/FolderProjectList.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,17 @@ private void updateProjectList() {
143143
listPanel.removeAll();
144144
listPanel.revalidate();
145145
listPanel.repaint();
146+
147+
PhonWorker worker = PhonWorker.createWorker();
148+
worker.setFinishWhenQueueEmpty(true);
146149

147150
boolean stripRow = false;
148151
for(MultiActionButton btn:projectButtons) {
149152
listPanel.add(btn);
153+
154+
if(btn instanceof LocalProjectButton) {
155+
((LocalProjectButton) btn).updateProjectSize(worker);
156+
}
150157

151158
if(stripRow) {
152159
btn.setBackground(PhonGuiConstants.PHON_UI_STRIP_COLOR);
@@ -156,7 +163,8 @@ private void updateProjectList() {
156163
stripRow = true;
157164
}
158165
}
159-
166+
167+
worker.start();
160168
revalidate();
161169
listPanel.revalidate();
162170
listPanel.repaint();

app/src/main/java/ca/phon/app/welcome/LocalProjectButton.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ public LocalProjectButton(File projFile) {
5757
setBackgroundPainter(bgPainter);
5858

5959
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
60+
}
6061

61-
PhonWorker.getInstance().invokeLater(new ProjectSizeCalcTask());
62+
public void updateProjectSize(PhonWorker worker) {
63+
worker.invokeLater(new ProjectSizeCalcTask());
6264
}
6365

6466
/**
@@ -158,8 +160,11 @@ private long getSize(File f) {
158160
// return size of file
159161
retVal = f.length();
160162
} else if(f.isDirectory()) {
161-
for(File lf:f.listFiles()) {
162-
retVal += getSize(lf);
163+
File[] files = f.listFiles();
164+
if(files != null) {
165+
for (File lf : files) {
166+
retVal += getSize(lf);
167+
}
163168
}
164169
}
165170
return retVal;

session/src/main/java/ca/phon/session/io/xml/v12/XMLSessionReader_v12.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,13 @@ public void visitCompoundPhone(CompoundPhone cp) {
643643
(eleIdx < syllabification.size() ? syllabification.get(eleIdx++) : null);
644644
if(ct != null) {
645645
final ConstituentTypeType ctt = ct.getScType();
646+
final SyllabificationInfo info = cp.getExtension(SyllabificationInfo.class);
646647
final SyllableConstituentType scType = SyllableConstituentType.fromString(ctt.toString());
647648
if(scType != null) {
648-
cp.setScType(scType);
649+
info.setConstituentType(scType);
650+
if(scType == SyllableConstituentType.NUCLEUS) {
651+
info.setDiphthongMember(!ct.isHiatus());
652+
}
649653
}
650654
}
651655
}

0 commit comments

Comments
 (0)