From 6c5645578aa390bbd67bf93740ba541cb2b22525 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@digia.com>
Date: Thu, 15 May 2014 15:01:21 +0200
Subject: [PATCH] Remove friends of QEvent.

Introduce function to set the spontaneous flag to
QCoreApplicationPrivate to solve a few cases.

Change-Id: I7c1f1f3644defe00deea9cecb244ca258afd5b94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
---
 src/corelib/kernel/qcoreapplication_p.h | 1 +
 src/corelib/kernel/qcoreevent.h         | 6 ------
 src/widgets/kernel/qapplication.cpp     | 2 +-
 src/widgets/kernel/qwidgetwindow.cpp    | 2 +-
 4 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index d784267a651..f0c9e4e1c2b 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -96,6 +96,7 @@ public:
     bool sendThroughApplicationEventFilters(QObject *, QEvent *);
     bool sendThroughObjectEventFilters(QObject *, QEvent *);
     bool notify_helper(QObject *, QEvent *);
+    static inline void setEventSpontaneous(QEvent *e, bool spontaneous) { e->spont = spontaneous; }
 
     virtual void createEventDispatcher();
     virtual void eventDispatcherReady();
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index a498afbb04d..cd7689f842f 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -318,16 +318,10 @@ private:
     friend class QCoreApplicationPrivate;
     friend class QThreadData;
     friend class QApplication;
-    friend class QApplicationPrivate;
     friend class QShortcutMap;
     friend class QGraphicsView;
-    friend class QGraphicsViewPrivate;
     friend class QGraphicsScene;
     friend class QGraphicsScenePrivate;
-    friend class QWidgetWindow;
-#ifndef QT_NO_GESTURES
-    friend class QGestureManager;
-#endif
 };
 
 class Q_CORE_EXPORT QTimerEvent : public QEvent
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 9c2c2bab162..703b748a562 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3505,7 +3505,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
 
     // deliver the event
     bool consumed = receiver->event(e);
-    e->spont = false;
+    QCoreApplicationPrivate::setEventSpontaneous(e, false);
     return consumed;
 }
 
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index fc328e7af0f..06a4d8c960e 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -443,7 +443,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
                         // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
                         const QPoint localPos = win->mapFromGlobal(event->globalPos());
                         QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
-                        e->spont = 1;
+                        QCoreApplicationPrivate::setEventSpontaneous(e, true);
                         QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
                         e->setTimestamp(event->timestamp());
                         QCoreApplication::postEvent(win, e);
-- 
GitLab