From 7e48b8e5be9204b88a753af54bfee6f68c62c0a9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 31 Aug 2010 17:41:34 +0200 Subject: [PATCH] Remove one hack of the QTipLabel hack. This code used two hacks: it created a class with metaObject()->className() == "QTipLabel" to fool the code in Qt into applying the style properly to this class. But it did that by creating a class called QTipLabel. This works as long as the class in Qt is hidden by symbol visibility. When symbol visibility is disabled (for whatever reason), then Creator simply crashes due to size mismatches and memory corruptions (virtual tables, etc.) This patch makes the class be called TextEditor::Internal::QTipLabel, but fools moc into thinking it isn't. A proper solution would be to simply override the meta object. Signed-off-by: Leandro Melo --- src/plugins/texteditor/tooltip/tipfactory.cpp | 2 +- src/plugins/texteditor/tooltip/tipfactory.h | 5 +---- src/plugins/texteditor/tooltip/tips.cpp | 14 ++++++++------ src/plugins/texteditor/tooltip/tips.h | 12 ++++++------ src/plugins/texteditor/tooltip/tooltip.h | 4 ++-- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/plugins/texteditor/tooltip/tipfactory.cpp b/src/plugins/texteditor/tooltip/tipfactory.cpp index ceeebe46cfb..435abbe6a91 100644 --- a/src/plugins/texteditor/tooltip/tipfactory.cpp +++ b/src/plugins/texteditor/tooltip/tipfactory.cpp @@ -40,7 +40,7 @@ TipFactory::TipFactory() TipFactory::~TipFactory() {} -QTipLabel *TipFactory::createTip(const TipContent &content, QWidget *w) +Internal::QTipLabel *TipFactory::createTip(const TipContent &content, QWidget *w) { QTipLabel *tip = 0; if (content.typeId() == TextContent::TEXT_CONTENT_ID) diff --git a/src/plugins/texteditor/tooltip/tipfactory.h b/src/plugins/texteditor/tooltip/tipfactory.h index 09710873a1e..ccd1d5d45a6 100644 --- a/src/plugins/texteditor/tooltip/tipfactory.h +++ b/src/plugins/texteditor/tooltip/tipfactory.h @@ -32,15 +32,12 @@ #include -QT_BEGIN_NAMESPACE -class QTipLabel; -QT_END_NAMESPACE - namespace TextEditor { class TipContent; namespace Internal { +class QTipLabel; class TipFactory { diff --git a/src/plugins/texteditor/tooltip/tips.cpp b/src/plugins/texteditor/tooltip/tips.cpp index 606d622590b..3492e5a2022 100644 --- a/src/plugins/texteditor/tooltip/tips.cpp +++ b/src/plugins/texteditor/tooltip/tips.cpp @@ -41,8 +41,8 @@ #include #include -using namespace TextEditor; -using namespace Internal; +namespace TextEditor { + namespace Internal { namespace { // @todo: Reuse... @@ -59,8 +59,6 @@ namespace { } } -QT_BEGIN_NAMESPACE - QTipLabel::QTipLabel(QWidget *parent) : QLabel(parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), m_tipContent(0) @@ -83,8 +81,6 @@ void QTipLabel::setContent(const TipContent &content) const TipContent &QTipLabel::content() const { return *m_tipContent; } -QT_END_NAMESPACE - ColorTip::ColorTip(QWidget *parent) : QTipLabel(parent) { resize(QSize(40, 40)); @@ -183,3 +179,9 @@ void TextTip::resizeEvent(QResizeEvent *event) QLabel::resizeEvent(event); } + +// need to include it here to force it to be inside the namespaces +#include "moc_tips.cpp" + +} // namespace Internal +} // namespace TextEditor diff --git a/src/plugins/texteditor/tooltip/tips.h b/src/plugins/texteditor/tooltip/tips.h index 38f73bc5cac..806124be306 100644 --- a/src/plugins/texteditor/tooltip/tips.h +++ b/src/plugins/texteditor/tooltip/tips.h @@ -38,7 +38,10 @@ namespace TextEditor { class TipContent; } -QT_BEGIN_NAMESPACE +#ifndef Q_MOC_RUN +namespace TextEditor { +namespace Internal { +#endif // Please do not change the name of this class. Detailed comments in tooltip.h. class QTipLabel : public QLabel @@ -60,11 +63,6 @@ private: TextEditor::TipContent *m_tipContent; }; -QT_END_NAMESPACE - -namespace TextEditor { -namespace Internal { - class ColorTip : public QTipLabel { Q_OBJECT @@ -96,7 +94,9 @@ private: virtual void resizeEvent(QResizeEvent *event); }; +#ifndef Q_MOC_RUN } // namespace Internal } // namespace TextEditor +#endif #endif // TIPS_H diff --git a/src/plugins/texteditor/tooltip/tooltip.h b/src/plugins/texteditor/tooltip/tooltip.h index def3bc7fc55..512ba610cf1 100644 --- a/src/plugins/texteditor/tooltip/tooltip.h +++ b/src/plugins/texteditor/tooltip/tooltip.h @@ -49,13 +49,13 @@ QT_BEGIN_NAMESPACE class QPoint; class QWidget; -class QTipLabel; QT_END_NAMESPACE namespace TextEditor { namespace Internal { class TipFactory; +class QTipLabel; } class TipContent; @@ -93,7 +93,7 @@ private: void hideTipWithDelay(); Internal::TipFactory *m_tipFactory; - QTipLabel *m_tip; + Internal::QTipLabel *m_tip; QWidget *m_widget; QRect m_rect; QTimer m_showTimer;