summaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-10-10 13:37:35 +0200
committerPierre Ossman <ossman@cendio.se>2014-10-10 13:37:35 +0200
commitd1a853bca7a70467915b3759aa9de5e63a5e8edb (patch)
tree5bcb8ba3e2095e27b45eca447ca4e933661e6647 /vncviewer
parent86750633ff7c5d8836b751148234ab94e132b0a5 (diff)
downloadtigervnc-d1a853bca7a70467915b3759aa9de5e63a5e8edb.tar.gz
tigervnc-d1a853bca7a70467915b3759aa9de5e63a5e8edb.zip
Use exceptions rather than asserts for for "normal" errors
Although these are rare, they are still not indicative of bugs so an exception (which ends up in the log and might also be shown to the user) is more appropriate than an assert. Asserts should only be used to catch blatant API misuse and similar.
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/OSXPixelBuffer.cxx9
-rw-r--r--vncviewer/Viewport.cxx3
-rw-r--r--vncviewer/X11PixelBuffer.cxx7
3 files changed, 11 insertions, 8 deletions
diff --git a/vncviewer/OSXPixelBuffer.cxx b/vncviewer/OSXPixelBuffer.cxx
index a3ee9d0d..e9100f27 100644
--- a/vncviewer/OSXPixelBuffer.cxx
+++ b/vncviewer/OSXPixelBuffer.cxx
@@ -20,8 +20,6 @@
#include <config.h>
#endif
-#include <assert.h>
-
#include <ApplicationServices/ApplicationServices.h>
#include <FL/Fl_Window.H>
@@ -50,13 +48,14 @@ OSXPixelBuffer::OSXPixelBuffer(int width, int height) :
throw rfb::Exception(_("Not enough memory for framebuffer"));
lut = CGColorSpaceCreateDeviceRGB();
- assert(lut);
+ if (!lut)
+ throw rfb::Exception(_("Could not create framebuffer device"));
bitmap = CGBitmapContextCreate(data, width, height, 8, width*4, lut,
kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little);
- assert(bitmap);
-
CGColorSpaceRelease(lut);
+ if (!bitmap)
+ throw rfb::Exception(_("Could not create framebuffer bitmap"));
}
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 66a78412..4daff164 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -27,6 +27,7 @@
#include <rfb/CMsgWriter.h>
#include <rfb/LogWriter.h>
+#include <rfb/Exception.h>
// FLTK can pull in the X11 headers on some systems
#ifndef XK_VoidSymbol
@@ -452,6 +453,8 @@ PlatformPixelBuffer* Viewport::createFramebuffer(int w, int h)
fb = new X11PixelBuffer(w, h);
#endif
} catch (rdr::Exception& e) {
+ vlog.error(_("Unable to create platform specific framebuffer: %s"), e.str());
+ vlog.error(_("Using platform independent framebuffer"));
fb = new FLTKPixelBuffer(w, h);
}
diff --git a/vncviewer/X11PixelBuffer.cxx b/vncviewer/X11PixelBuffer.cxx
index d84357c4..59b90e2c 100644
--- a/vncviewer/X11PixelBuffer.cxx
+++ b/vncviewer/X11PixelBuffer.cxx
@@ -21,7 +21,6 @@
#include <config.h>
#endif
-#include <assert.h>
#include <stdlib.h>
#include <FL/x.H>
@@ -104,10 +103,12 @@ X11PixelBuffer::X11PixelBuffer(int width, int height) :
if (!setupShm()) {
xim = XCreateImage(fl_display, fl_visual->visual, fl_visual->depth,
ZPixmap, 0, 0, width, height, BitmapPad(fl_display), 0);
- assert(xim);
+ if (!xim)
+ throw rfb::Exception(_("Could not create framebuffer image"));
xim->data = (char*)malloc(xim->bytes_per_line * xim->height);
- assert(xim->data);
+ if (!xim->data)
+ throw rfb::Exception(_("Not enough memory for framebuffer"));
}
data = (rdr::U8*)xim->data;