mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Replaced the QET_TBT_USE_QPICTURE_BASED_CACHE compile-time option with a hardcoded runtime check.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1536 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -163,13 +163,3 @@ unix {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# From Qt 4.8, we disable the QPicture-based cache for titleblock rendering
|
||||
# because it leads to bad rendering then crash.
|
||||
contains(QT_VERSION, ^4\\.[0-7]\\..*) {
|
||||
message("Detected Qt < 4.8: enabling QPicture-based cache for titleblock rendering.")
|
||||
DEFINES += QET_TBT_USE_QPICTURE_BASED_CACHE
|
||||
} else {
|
||||
message("Detected Qt >= 4.8: disabling QPicture-based cache for titleblock rendering.")
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
|
||||
titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
|
||||
titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
|
||||
|
||||
// disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
|
||||
if (!QRegExp("4\\.[0-7]\\.").exactMatch(qVersion())) {
|
||||
titleblock_template_renderer -> setUseCache(false);
|
||||
}
|
||||
|
||||
// dimensions par defaut du schema
|
||||
importBorder(BorderProperties());
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
TitleBlockTemplateRenderer::TitleBlockTemplateRenderer(QObject *parent) :
|
||||
QObject(parent),
|
||||
titleblock_template_(0),
|
||||
use_cache_(true),
|
||||
last_known_titleblock_width_(-1)
|
||||
{
|
||||
}
|
||||
@@ -61,18 +62,18 @@ int TitleBlockTemplateRenderer::height() const {
|
||||
void TitleBlockTemplateRenderer::render(QPainter *provided_painter, int titleblock_width) {
|
||||
if (!titleblock_template_) return;
|
||||
|
||||
#ifdef QET_TBT_USE_QPICTURE_BASED_CACHE
|
||||
// Do we really need to calculate all this again?
|
||||
if (titleblock_width != last_known_titleblock_width_ || rendered_template_.isNull()) {
|
||||
renderToQPicture(titleblock_width);
|
||||
}
|
||||
if (use_cache_) {
|
||||
// Do we really need to calculate all this again?
|
||||
if (titleblock_width != last_known_titleblock_width_ || rendered_template_.isNull()) {
|
||||
renderToQPicture(titleblock_width);
|
||||
}
|
||||
|
||||
provided_painter -> save();
|
||||
rendered_template_.play(provided_painter);
|
||||
provided_painter -> restore();
|
||||
#else
|
||||
titleblock_template_ -> render(*provided_painter, context_, titleblock_width);
|
||||
#endif
|
||||
provided_painter -> save();
|
||||
rendered_template_.play(provided_painter);
|
||||
provided_painter -> restore();
|
||||
} else {
|
||||
titleblock_template_ -> render(*provided_painter, context_, titleblock_width);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,3 +99,20 @@ void TitleBlockTemplateRenderer::renderToQPicture(int titleblock_width) {
|
||||
void TitleBlockTemplateRenderer::invalidateRenderedTemplate() {
|
||||
rendered_template_ = QPicture();
|
||||
}
|
||||
|
||||
/**
|
||||
@param use_cache true for this renderer to use its QPicture-based cache,
|
||||
false otherwise.
|
||||
*/
|
||||
void TitleBlockTemplateRenderer::setUseCache(bool use_cache) {
|
||||
use_cache_ = use_cache;
|
||||
}
|
||||
|
||||
/**
|
||||
@return true if this renderer uses its QPicture-based cache, false
|
||||
otherwise.
|
||||
*/
|
||||
bool TitleBlockTemplateRenderer::useCache() const {
|
||||
return(use_cache_);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,12 +32,15 @@ class TitleBlockTemplateRenderer : public QObject {
|
||||
int height() const;
|
||||
void render(QPainter *, int);
|
||||
void invalidateRenderedTemplate();
|
||||
void setUseCache(bool);
|
||||
bool useCache() const;
|
||||
|
||||
private:
|
||||
void renderToQPicture(int);
|
||||
|
||||
private:
|
||||
const TitleBlockTemplate *titleblock_template_;
|
||||
bool use_cache_;
|
||||
QPicture rendered_template_;
|
||||
DiagramContext context_;
|
||||
int last_known_titleblock_width_;
|
||||
|
||||
Reference in New Issue
Block a user