47 lines
1.2 KiB
Diff
47 lines
1.2 KiB
Diff
This patch fixes a bug where hitting Del on a Mail window that wasn't saved would error, but not allow itself to be saved. After this patch, hitting Del informs the user the window is dirty, but still allows the Put command to succeed.
|
|
diff 3a1a463df4f4c5c8fc8eb1ac023c73713415eb2c uncommitted
|
|
--- a/sys/src/cmd/upas/Mail/mail.h
|
|
+++ b/sys/src/cmd/upas/Mail/mail.h
|
|
@@ -146,6 +146,7 @@
|
|
int view;
|
|
int nopen;
|
|
char *path;
|
|
+ int quitting;
|
|
};
|
|
|
|
extern Mbox mbox;
|
|
--- a/sys/src/cmd/upas/Mail/mbox.c
|
|
+++ b/sys/src/cmd/upas/Mail/mbox.c
|
|
@@ -451,6 +451,7 @@
|
|
{
|
|
int i, n, fd;
|
|
Dir *d;
|
|
+ mbox.quitting = 0;
|
|
|
|
mbox.mesgsz = 128;
|
|
mbox.hashsz = 128;
|
|
@@ -796,6 +797,7 @@
|
|
{
|
|
Mesg *m;
|
|
Comp *c;
|
|
+ char d;
|
|
|
|
if(mbox.nopen > 0 && !mbox.canquit){
|
|
fprint(2, "Del: %d open messages\n", mbox.nopen);
|
|
@@ -806,7 +808,15 @@
|
|
fprint(m->ctl, "del\n");
|
|
for(c = mbox.opencomp; c != nil; c = c->qnext)
|
|
fprint(c->ctl, "del\n");
|
|
- fprint(mbox.ctl, "del\n");
|
|
+ /* check if mbox has unsaved changes by reading dirty flag before closing */
|
|
+ pread(mbox.ctl, &d, 1, 58);
|
|
+ if(d == '1' && mbox.quitting == 0){
|
|
+ fprint(2, "unsaved changes in mailbox\n");
|
|
+ mbox.quitting++;
|
|
+ return;
|
|
+ }
|
|
+ else
|
|
+ fprint(mbox.ctl, "delete\n");
|
|
threadexitsall(nil);
|
|
}
|
|
|