author | mickeyl <mickeyl> | 2004-05-13 21:56:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-13 21:56:23 (UTC) |
commit | f005863ac3e3106f3da9fd337ab0a20da0cd4b83 (patch) (unidiff) | |
tree | b633e278659c87b7bc964bb5ea80d46131798960 | |
parent | 6841da6429d864d5554c5a16e87c2755fe96343b (diff) | |
download | opie-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() ) );
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 3 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/main.cpp | 1 |
5 files changed, 11 insertions, 6 deletions
@@ -1,5 +1,6 @@ | |||
1 | 2004-??-??The Opie Team <opie@handhelds.org> | 1 | 2004-??-??The Opie Team <opie@handhelds.org> |
2 | 2 | ||
3 | * Fixed Drawpad initialization (Bug #1314) (mickeyl) | ||
3 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) | 4 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) |
4 | * Added Conversion tool for pim-data (eilers) | 5 | * Added Conversion tool for pim-data (eilers) |
5 | * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers) | 6 | * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers) |
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 @@ | |||
49 | #include <qwhatsthis.h> | 49 | #include <qwhatsthis.h> |
50 | 50 | ||
51 | using namespace Opie::Ui; | 51 | using namespace Opie::Ui; |
52 | using namespace Opie::Ui; | ||
53 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) | 52 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) |
54 | : QMainWindow(parent, name, WStyle_ContextHelp) | 53 | : QMainWindow(parent, name, WStyle_ContextHelp) |
55 | { | 54 | { |
@@ -281,7 +280,10 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) | |||
281 | 280 | ||
282 | changeBrushColor(Qt::white); | 281 | changeBrushColor(Qt::white); |
283 | 282 | ||
284 | finishStartup(); | 283 | // delay the rest of the initialization and do it from within the mainloop |
284 | // if we don't do this, the widget layout may not be constructed upon | ||
285 | // and we will end up with a wrong QScrollview page size (Mickeyl) | ||
286 | QTimer::singleShot( 100, this, SLOT( finishStartup() ) ); | ||
285 | } | 287 | } |
286 | 288 | ||
287 | 289 | ||
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: | |||
41 | QBrush brush() { return m_brush; } | 41 | QBrush brush() { return m_brush; } |
42 | 42 | ||
43 | bool antiAliasing(); | 43 | bool antiAliasing(); |
44 | void finishStartup(); | ||
45 | 44 | ||
46 | private slots: | 45 | private slots: |
46 | void finishStartup(); | ||
47 | |||
47 | void newPage(); | 48 | void newPage(); |
48 | void clearPage(); | 49 | void clearPage(); |
49 | void deletePage(); | 50 | 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) | |||
516 | 516 | ||
517 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 517 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
518 | { | 518 | { |
519 | Page* currentPage = m_pages.current(); | ||
520 | if ( !currentPage ) return; // no page yet --> initialization not finished (Mickeyl) | ||
519 | QRect clipRect(cx, cy, cw, ch); | 521 | QRect clipRect(cx, cy, cw, ch); |
520 | QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 522 | QRect pixmapRect(0, 0, currentPage->pixmap()->width(), m_pages.current()->pixmap()->height()); |
521 | QRect drawRect = pixmapRect.intersect(clipRect); | 523 | QRect drawRect = pixmapRect.intersect(clipRect); |
522 | 524 | ||
523 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect); | 525 | p->drawPixmap(drawRect.topLeft(), *(currentPage->pixmap()), drawRect); |
524 | 526 | ||
525 | if (drawRect.right() < clipRect.right()) { | 527 | if (drawRect.right() < clipRect.right()) { |
526 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); | 528 | 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 @@ | |||
16 | #include <opie2/oapplicationfactory.h> | 16 | #include <opie2/oapplicationfactory.h> |
17 | 17 | ||
18 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
19 | using namespace Opie::Core; | ||
20 | OPIE_EXPORT_APP( OApplicationFactory<DrawPad> ) | 19 | OPIE_EXPORT_APP( OApplicationFactory<DrawPad> ) |