Properly implement saveState / restoreState
Not all of the internal state was actually saved/restored in
those methods, which lead to inconsistencies between the
ArthurOutputDev state and the GfxState object.
Bug #103118
diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc
index f199e65..3be1267 100644
--- a/qt5/src/ArthurOutputDev.cc
+++ b/qt5/src/ArthurOutputDev.cc
@@ -137,12 +137,26 @@
void ArthurOutputDev::saveState(GfxState *state)
{
+ m_currentPenStack.push(m_currentPen);
+ m_currentBrushStack.push(m_currentBrush);
+ m_rawFontStack.push(m_rawFont);
+ m_codeToGIDStack.push(m_codeToGID);
+
m_painter->save();
}
void ArthurOutputDev::restoreState(GfxState *state)
{
m_painter->restore();
+
+ m_codeToGID = m_codeToGIDStack.top();
+ m_codeToGIDStack.pop();
+ m_rawFont = m_rawFontStack.top();
+ m_rawFontStack.pop();
+ m_currentBrush = m_currentBrushStack.top();
+ m_currentBrushStack.pop();
+ m_currentPen = m_currentPenStack.top();
+ m_currentPenStack.pop();
}
void ArthurOutputDev::updateAll(GfxState *state)
diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h
index 496f5a7..480c782 100644
--- a/qt5/src/ArthurOutputDev.h
+++ b/qt5/src/ArthurOutputDev.h
@@ -36,6 +36,7 @@
#include <memory>
#include <map>
+#include <stack>
#include "goo/gtypes.h"
#include "OutputDev.h"
@@ -172,14 +173,21 @@
private:
QPainter *m_painter;
FontHinting m_fontHinting;
+
QPen m_currentPen;
+ // The various stacks are used to implement the 'saveState' and 'restoreState' methods
+ std::stack<QPen> m_currentPenStack;
+
QBrush m_currentBrush;
+ std::stack<QBrush> m_currentBrushStack;
+
GBool m_needFontUpdate; // set when the font needs to be updated
SplashFontEngine *m_fontEngine;
XRef *xref; // xref table for current document
// The current font in use
QRawFont* m_rawFont;
+ std::stack<QRawFont*> m_rawFontStack;
// Identify a font by its 'Ref' and its font size
struct ArthurFontID
@@ -199,6 +207,7 @@
// The table that maps character codes to glyph indexes
int* m_codeToGID;
+ std::stack<int*> m_codeToGIDStack;
};
#endif