summaryrefslogtreecommitdiff
path: root/noncore
authormickeyl <mickeyl>2004-05-13 21:56:23 (UTC)
committer mickeyl <mickeyl>2004-05-13 21:56:23 (UTC)
commitf005863ac3e3106f3da9fd337ab0a20da0cd4b83 (patch) (side-by-side diff)
treeb633e278659c87b7bc964bb5ea80d46131798960 /noncore
parent6841da6429d864d5554c5a16e87c2755fe96343b (diff)
downloadopie-f005863ac3e3106f3da9fd337ab0a20da0cd4b83.zip
opie-f005863ac3e3106f3da9fd337ab0a20da0cd4b83.tar.gz
opie-f005863ac3e3106f3da9fd337ab0a20da0cd4b83.tar.bz2
BUGFIX for 1314: Fix page initialization on first start of drawpad.
Problem was caused by a race condition. Developers: If you have todo initializations which depend on the widget layout being finished, _don't_ do this in the widget constructor but in a callback from the mainloop, i.e. via QTimer::singleShot( 10, this, SLOT( myInitialization() ) );
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp6
-rw-r--r--noncore/graphics/drawpad/drawpad.h3
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp6
-rw-r--r--noncore/graphics/drawpad/main.cpp1
4 files changed, 10 insertions, 6 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index d9d0ce0..c0f42d9 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -49,7 +49,6 @@
#include <qwhatsthis.h>
using namespace Opie::Ui;
-using namespace Opie::Ui;
DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ )
: QMainWindow(parent, name, WStyle_ContextHelp)
{
@@ -281,7 +280,10 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ )
changeBrushColor(Qt::white);
- finishStartup();
+ // delay the rest of the initialization and do it from within the mainloop
+ // if we don't do this, the widget layout may not be constructed upon
+ // and we will end up with a wrong QScrollview page size (Mickeyl)
+ QTimer::singleShot( 100, this, SLOT( finishStartup() ) );
}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index ba9e47d..63d3057 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -41,9 +41,10 @@ public:
QBrush brush() { return m_brush; }
bool antiAliasing();
- void finishStartup();
private slots:
+ void finishStartup();
+
void newPage();
void clearPage();
void deletePage();
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 423ef26..5d0c6e4 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -516,11 +516,13 @@ void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e)
void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
{
+ Page* currentPage = m_pages.current();
+ if ( !currentPage ) return; // no page yet --> initialization not finished (Mickeyl)
QRect clipRect(cx, cy, cw, ch);
- QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
+ QRect pixmapRect(0, 0, currentPage->pixmap()->width(), m_pages.current()->pixmap()->height());
QRect drawRect = pixmapRect.intersect(clipRect);
- p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect);
+ p->drawPixmap(drawRect.topLeft(), *(currentPage->pixmap()), drawRect);
if (drawRect.right() < clipRect.right()) {
p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark());
diff --git a/noncore/graphics/drawpad/main.cpp b/noncore/graphics/drawpad/main.cpp
index e48bb2e..f468022 100644
--- a/noncore/graphics/drawpad/main.cpp
+++ b/noncore/graphics/drawpad/main.cpp
@@ -16,5 +16,4 @@
#include <opie2/oapplicationfactory.h>
using namespace Opie::Core;
-using namespace Opie::Core;
OPIE_EXPORT_APP( OApplicationFactory<DrawPad> )