From 4f0b6320a769925e69fa04ebd3358894e706b52e Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 21 Sep 2012 19:41:01 -0500 Subject: Attempt to work around Qt 4.8 bug in fromX11Pixmap when masks are converted --- lib/tdeqt4painter.cpp | 32 ++++++++++++++++++++++++++++++++ plugin/simplestyle.cpp | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/tdeqt4painter.cpp b/lib/tdeqt4painter.cpp index 6bc09d1..2e22ebf 100644 --- a/lib/tdeqt4painter.cpp +++ b/lib/tdeqt4painter.cpp @@ -31,6 +31,11 @@ #include "tdeqt4converter.h" +#define SET_BIT(x, y) (x |= 1 << y) +#define TEST_BIT(x, y) ((x & (1 << y)) >> y) + +// #define USE_FROMX11_PIXMAP + /*! \class TDEQt4PaintDevice tdeqt4painter.h \brief The TDEQt4PaintDevice class is a paint device that translates @@ -121,6 +126,7 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) // SLOW TQRect tqt3br = p[0].rgn->boundingRect(); if (!tqt3br.isNull()) { +#ifdef USE_FROMX11_PIXMAP TQBitmap regionMask(tqt3br.x()+tqt3br.width(), tqt3br.y()+tqt3br.height()); regionMask.fill(TQt::color0); TQPainter tqt3brpainter(®ionMask); @@ -128,6 +134,32 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) tqt3brpainter.fillRect(0,0,regionMask.width(),regionMask.height(),TQt::color1); tqt3brpainter.end(); QBitmap qt4RegionMask = QPixmap::fromX11Pixmap(regionMask.handle(), QPixmap::ImplicitlyShared); +#else // USE_FROMX11_PIXMAP + TQBitmap regionMask(tqt3br.x()+tqt3br.width(), tqt3br.y()+tqt3br.height(), 32); + int width = regionMask.width(); + int height = regionMask.height(); + int size = (((width*height)/8)+1); + unsigned char* monoData = (unsigned char*)malloc(size); + memset(monoData, 0, size); + int x; + int y; + int byte = 0; + int bit = 7; + for (x=0; xcontains(TQPoint(x,y))) { + SET_BIT(monoData[byte], bit); + } + bit--; + if (bit < 0) { + bit = 7; + byte++; + } + } + } + QBitmap qt4RegionMask = QBitmap::fromData(QSize(width, height), monoData, QImage::Format_Mono); + free(monoData); +#endif // USE_FROMX11_PIXMAP qt4region = QRegion(qt4RegionMask); #endif TQPainter::CoordinateMode tqt3coordmode = (TQPainter::CoordinateMode)p[1].ival; diff --git a/plugin/simplestyle.cpp b/plugin/simplestyle.cpp index 739b4c6..d40d457 100644 --- a/plugin/simplestyle.cpp +++ b/plugin/simplestyle.cpp @@ -242,7 +242,8 @@ Qt4TDEStyle::Qt4TDEStyle() : m_aboutData(NULL), m_tqApplication(NULL), m_tdeAppl #if QT_VERSION > 0x040800 // How a bug of this magnitude could go undetected in a major Qt4 release is beyond me...I guess cell phones don't generally use thin lines in their widgets!? // This is Yet Another Example of why TDE cannot rely on Qt4 for anything of any real importance - printf("[WARNING] Qt4 >= Qt 4.8.0 detected; you are likely affected by these Qt4 bugs:\n\r[WARNING] https://bugreports.qt-project.org/browse/QTBUG-25896\n\r[WARNING] https://bugreports.qt-project.org/browse/QTBUG-26013\n\r[WARNING] There is no known workaround for this problem; your Qt4 application will display with numerous graphical glitches.\n\r"); fflush(stdout); + printf("[WARNING] Qt4 >= Qt 4.8.0 detected; you are likely affected by these Qt4 bugs:\n\r[WARNING] https://bugreports.qt-project.org/browse/QTBUG-25896\n\r[WARNING] https://bugreports.qt-project.org/browse/QTBUG-26013\n\r[WARNING] There is no known workaround for this problem; your Qt4 application will display with numerous graphical glitches.\n\r"); + printf("[WARNING] You are also likely affected by a bug in QPixmap::fromX11Pixmap, which will result\n\r[WARNING] in qtoctave and similar applications failing to display, along with numerous BadDrawable errors!\n\r"); fflush(stdout); #endif } -- cgit v1.2.3