OSDN Git Service

drop support for printing location of signals and slots
authorIvailo Monev <xakepa10@gmail.com>
Mon, 21 Dec 2020 22:49:07 +0000 (22:49 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 21 Dec 2020 23:11:51 +0000 (23:11 +0000)
storing the location in per-thread data and accessing that is just bad
idea considering it can be implemented as additional optional argument
that defaults to Q_FUNC_INFO passed to QObject::connect()
and QObject::disconnect(), there will be no performance penatly for
non-debug type builds too

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/global/qconfig.h.cmake
src/core/kernel/qobject.cpp
src/core/kernel/qobjectdefs.h
src/core/thread/qthread_p.h

index 1d36576..48fd4c3 100644 (file)
 #cmakedefine QT_NO_DRAGANDDROP
 #cmakedefine QT_NO_DYNAMIC_CAST
 #cmakedefine QT_NO_EFFECTS
-#cmakedefine QT_NO_EMIT
 #cmakedefine QT_NO_ERRORMESSAGE
 #cmakedefine QT_NO_FILEDIALOG
 #cmakedefine QT_NO_FILEICONPROVIDER
index 5eb84ee..044638f 100644 (file)
@@ -1705,30 +1705,12 @@ QString QObject::trUtf8(const char *sourceText)
   Signals and slots
  *****************************************************************************/
 
-
-const char *qFlagLocation(const char *method)
-{
-    QThreadData::current()->flaggedSignatures.store(method);
-    return method;
-}
-
 static inline int extract_code(const char *member)
 {
     // extract code, ensure QMETHOD_CODE <= code <= QSIGNAL_CODE
     return (((int)(*member) - '0') & 0x3);
 }
 
-static const char * extract_location(const char *member)
-{
-    if (QThreadData::current()->flaggedSignatures.contains(member)) {
-        // signature includes location information after the first null-terminator
-        const char *location = member + qstrlen(member) + 1;
-        if (*location != '\0')
-            return location;
-    }
-    return Q_NULLPTR;
-}
-
 static bool check_signal_macro(const QObject *sender, const char *signal,
                                 const char *func, const char *op)
 {
@@ -1765,16 +1747,8 @@ static void err_method_notfound(const QObject *object,
         case QSLOT_CODE:   type = "slot";   break;
         case QSIGNAL_CODE: type = "signal"; break;
     }
-    const char *loc = extract_location(method);
-    if (strchr(method,')') == 0) {               // common typing mistake
-        qWarning("Object::%s: Parentheses expected, %s %s::%s%s%s",
-                 func, type, object->metaObject()->className(), method+1,
-                 loc ? " in ": "", loc ? loc : "");
-    } else {
-        qWarning("Object::%s: No such %s %s::%s%s%s",
-                 func, type, object->metaObject()->className(), method+1,
-                 loc ? " in ": "", loc ? loc : "");
-    }
+    qWarning("Object::%s: No such %s %s::%s",
+             func, type, object->metaObject()->className(), method+1);
 }
 
 
@@ -2316,13 +2290,12 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
 
     QByteArray method_name;
     const char *method_arg = method;
-    int membcode = -1;
     bool method_found = false;
     if (method) {
         method_name = QMetaObject::normalizedSignature(method);
         method = method_name.constData();
 
-        membcode = extract_code(method);
+        int membcode = extract_code(method);
         if (!check_method_code(membcode, receiver, method, "disconnect"))
             return false;
         method++; // skip code
index 0e61e9d..ef749dd 100644 (file)
@@ -53,19 +53,15 @@ class QString;
 // They are used, strictly speaking, only by the moc.
 
 #ifndef Q_MOC_RUN
-# if defined(QT_NO_KEYWORDS)
-#  define QT_NO_EMIT
-# else
+# ifndef QT_NO_KEYWORDS
 #   define slots
 #   define signals protected
+#   define emit
 # endif
-# define Q_SLOTS
-# define Q_SIGNALS protected
-# define Q_PRIVATE_SLOT(d, signature)
-# define Q_EMIT
-#ifndef QT_NO_EMIT
-# define emit
-#endif
+#define Q_SLOTS
+#define Q_SIGNALS protected
+#define Q_PRIVATE_SLOT(d, signature)
+#define Q_EMIT
 #define Q_CLASSINFO(name, value)
 #define Q_INTERFACES(x)
 #define Q_PROPERTY(text)
@@ -151,38 +147,17 @@ private:
 #define Q_SLOT Q_SLOT
 #endif //Q_MOC_RUN
 
-// macro for onaming members
-#ifdef METHOD
-#undef METHOD
-#endif
-#ifdef SLOT
-#undef SLOT
-#endif
-#ifdef SIGNAL
-#undef SIGNAL
-#endif
-
-Q_CORE_EXPORT const char *qFlagLocation(const char *method);
-
-#ifndef QT_NO_DEBUG
-# ifndef QT_NO_KEYWORDS
-#  define METHOD(a)   qFlagLocation("0"#a "\0" Q_FUNC_INFO)
-# endif
-# define SLOT(a)     qFlagLocation("1"#a "\0" Q_FUNC_INFO)
-# define SIGNAL(a)   qFlagLocation("2"#a "\0" Q_FUNC_INFO)
-#else
-# ifndef QT_NO_KEYWORDS
-#  define METHOD(a)   "0"#a
-# endif
-# define SLOT(a)     "1"#a
-# define SIGNAL(a)   "2"#a
-#endif
-
-
-#define QMETHOD_CODE  0                        // member type codes
+// definitions and macros for identifying connection types
+#define QMETHOD_CODE  0
 #define QSLOT_CODE    1
 #define QSIGNAL_CODE  2
 
+#ifndef QT_NO_KEYWORDS
+# define METHOD(a)   "0"#a
+#endif
+#define SLOT(a)     "1"#a
+#define SIGNAL(a)   "2"#a
+
 #define Q_ARG(type, data) QArgument<type >(#type, data)
 #define Q_RETURN_ARG(type, data) QReturnArgument<type >(#type, data)
 
index b6f2ad1..d210d14 100644 (file)
@@ -190,34 +190,6 @@ public:
         return canWait;
     }
 
-    // This class provides per-thread (by way of being a QThreadData
-    // member) storage for qFlagLocation()
-    class FlaggedDebugSignatures
-    {
-        static const uint Count = 2;
-
-        uint idx;
-        const char* locations[Count];
-
-    public:
-        FlaggedDebugSignatures() : idx(0)
-        {
-            for (uint i = 0; i < Count; ++i)
-                locations[i] = Q_NULLPTR;
-        }
-
-        void store(const char* method)
-        { locations[idx++ % Count] = method; }
-
-        bool contains(const char *method) const
-        {
-            for (uint i = 0; i < Count; ++i)
-                if (locations[i] == method)
-                    return true;
-            return false;
-        }
-    };
-
     bool quitNow;
     bool canWait;
     bool isAdopted;
@@ -228,7 +200,6 @@ public:
     QThread *thread;
     QAbstractEventDispatcher *eventDispatcher;
     QPostEventList postEventList;
-    FlaggedDebugSignatures flaggedSignatures;
 
 private:
     QAtomicInt _ref;