Commit 7e48b8e5 authored by Thiago Macieira's avatar Thiago Macieira Committed by Leandro Melo
Browse files

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: default avatarLeandro Melo <leandro.melo@nokia.com>
parent 67d0ab3f
......@@ -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)
......
......@@ -32,15 +32,12 @@
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class QTipLabel;
QT_END_NAMESPACE
namespace TextEditor {
class TipContent;
namespace Internal {
class QTipLabel;
class TipFactory
{
......
......@@ -41,8 +41,8 @@
#include <QtGui/QStylePainter>
#include <QtGui/QStyleOptionFrame>
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
......@@ -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
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment