summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 5d0c6e4..5b1aa7e 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -176,10 +176,26 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
xmlSimpleReader.parse(xmlInputSource);
+ /*
+ * we could have loaded something from setDocument already
+ * due the delayed loading we need to make sure we do
+ * not lose pages
+ */
+ if ( !m_pages.isEmpty() ) {
+ QList<Page> pages = drawPadCanvasXmlHandler.pages();
+ QListIterator<Page> it( pages );
+ Page *p;
+ while ( ( p = it.current() ) ) {
+ ++it;
+ m_pages.append( p );
+ }
+ }else
m_pages = drawPadCanvasXmlHandler.pages();
+
+
if (m_pages.isEmpty()) {
m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
@@ -193,8 +209,15 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
}
void DrawPadCanvas::initialPage()
{
+ /*
+ * by setDocument we've set a page already so
+ * don't add an empty one. This comes due the delayed initialisation
+ */
+ if (!m_pages.isEmpty() )
+ return;
+
m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
//236, 232)); no more fixed sizes