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 potential crash on PFile #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
17 changes: 16 additions & 1 deletion src/cuploader/PFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public final class PFile extends javax.swing.JPanel implements KeyListener {
int rotateThumb = 0; //rotate thumbnail
FInfo fExif; // subwindow exif
public FCoord fCoord; // subwindow coordinates
boolean ready = false;

//info
public File file;
Expand All @@ -83,9 +84,11 @@ public PFile(File file, int number) {
this.number = number;

initComponents();
ready = true;
addUndo();
addKeyListener(this);
TransferFocus.patch(tDesc);
ready = true;

String name = file.getName();
tName.setText(name.substring(0, name.lastIndexOf('.')));
Expand All @@ -109,6 +112,7 @@ public PFile(File file, int number, boolean toUpload, boolean toEdit, String nam
}

initComponents();
ready = true;
addUndo();
addKeyListener(this);
TransferFocus.patch(tDesc);
Expand Down Expand Up @@ -1137,7 +1141,9 @@ public void generateThumbnail() {

@Override
public void setName(String text) {
tName.setText(text);
if (ready) {
tName.setText(text);
};
}

public void setDate(String text) {
Expand Down Expand Up @@ -1187,6 +1193,15 @@ public String getComponent(Elem component) {
}
}

@Override
public String getName() {
if (ready) {
return tName.getText();
} else {
return "";
}
};

public String getExt() { return ext; };

public void setAsUploaded() {
Expand Down