ref: 4dd4213677184294116caee0a41b169324bccba1
parent: 92874574e446b3eaf22291772ca0737456d2e0c5
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Sat Dec 10 18:01:15 EST 2011
handle initdraw errors
--- a/sys/src/cmd/kbmap.c
+++ b/sys/src/cmd/kbmap.c
@@ -229,7 +229,10 @@
} else
init();
- initdraw(0, 0, "kbmap");
+ if(initdraw(0, 0, "kbmap") < 0){
+ fprint(2, "kbmap: initdraw failed: %r\n");
+ exits("initdraw");
+ }
lightblue = allocimagemix(display, DPalebluegreen, DWhite);
if(lightblue == nil)
sysfatal("allocimagemix: %r");
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -292,8 +292,8 @@
close(errfile);
}
logfile=mkmfile("mothra.log", 0666|DMAPPEND);
-
- initdraw(err,0,"mothra");
+ if(initdraw(err, 0, "mothra") < 0)
+ sysfatal("initdraw: %r");
display->locking = 1;
chrwidth=stringwidth(font, "0");
pltabsize(chrwidth, 8*chrwidth);
--- a/sys/src/cmd/mug.c
+++ b/sys/src/cmd/mug.c
@@ -1041,7 +1041,7 @@
fd = 0;
if (initdraw(0, 0, "mug") < 0)
- sysfatal("initdraw failed");
+ sysfatal("initdraw failed: %r");
if((orig = readimage(display, fd, 0)) == nil)
sysfatal("readimage: %r");
--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -1228,7 +1228,8 @@
sysfatal("newwindow: %r");
free(s);
}
- initdraw(drawerr, nil, argv0);
+ if(initdraw(drawerr, nil, argv0) < 0)
+ sysfatal("initdraw: %r");
paper = display->white;
frame = display->black;
ground = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF);
--- a/sys/src/cmd/paint.c
+++ b/sys/src/cmd/paint.c
@@ -43,7 +43,11 @@
char file[128];
haslast = 0;
- initdraw(0, 0, 0);
+ if(initdraw(0, 0, "paint") < 0){
+ fprint(2, "paint: initdraw failed: %r\n");
+ exits("initdraw");
+ }
+
einit(Emouse | Ekeyboard);
draw(screen, screen->r, display->white, 0, ZP);
flushimage(display, 1);
--- a/sys/src/cmd/vnc/rlist.c
+++ b/sys/src/cmd/vnc/rlist.c
@@ -273,7 +273,10 @@
Rectangle r3 = Rect(200, 100, 500, 300);
Region reg;
- initdraw(0, 0, "vncviewer");
+ if(initdraw(0, 0, "vncviewer") < 0){
+ fprint(2, "%s: initdraw failed: %r\n", argv[0]);
+ exits("initdraw");
+ }
region_init(®);
region_union(®, r1, r1);
region_union(®, r2, r2);
--- a/sys/src/cmd/vnc/vncv.c
+++ b/sys/src/cmd/vnc/vncv.c
@@ -132,7 +132,8 @@
if(vncstart(vnc, shared) < 0)
sysfatal("init failure: %r");
- initdraw(0, 0, "vncv");
+ if(initdraw(0, 0, "vncv") < 0)
+ sysfatal("initdraw: %r");
display->locking = 1;
unlockdisplay(display);
--- a/sys/src/cmd/winwatch.c
+++ b/sys/src/cmd/winwatch.c
@@ -262,14 +262,11 @@
if(argc)
usage();
- initdraw(0, 0, "winwatch");
+ if(initdraw(0, fontname, "winwatch") < 0)
+ sysfatal("initdraw: %r");
lightblue = allocimagemix(display, DPalebluegreen, DWhite);
if(lightblue == nil)
sysfatal("allocimagemix: %r");
-
- if(fontname)
- if((font = openfont(display, fontname)) == nil)
- sysfatal("font '%s' not found", fontname);
refreshwin();
redraw(screen, 1);