Make sure the fill function pointer gets updated if the
managed pixel buffer changes format. Also add a bit more
protection for switching pixel format as the base classes
aren't really designed for that. Fixes a crash with the
mouse pointer in WinVNC.
Based on work done by Daniel Wyatt (dewyatt).


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5152 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index 106b42b..60957a2 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -133,6 +133,22 @@
                                            rdr::U8* data_, ColourMap* cm)
   : PixelBuffer(pf, w, h, cm), data(data_)
 {
+  // Called again to configure the fill function
+  setPF(pf);
+}
+
+FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {}
+
+FullFramePixelBuffer::~FullFramePixelBuffer() {}
+
+
+void FullFramePixelBuffer::setPF(const PixelFormat &pf) {
+  // We have this as a separate method for ManagedPixelBuffer's
+  // sake. Direct users of FullFramePixelBuffer aren't allowed
+  // to call it.
+
+  PixelBuffer::setPF(pf);
+
   switch(pf.bpp) {
   case 8:
     fillRectFn = fillRect8;
@@ -148,10 +164,6 @@
   }
 }
 
-FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {}
-
-FullFramePixelBuffer::~FullFramePixelBuffer() {}
-
 
 int FullFramePixelBuffer::getStride() const { return width(); }
 
@@ -334,7 +346,7 @@
 
 void
 ManagedPixelBuffer::setPF(const PixelFormat &pf) {
-  format = pf; checkDataSize();
+  FullFramePixelBuffer::setPF(pf); checkDataSize();
 };
 void
 ManagedPixelBuffer::setSize(int w, int h) {