Qt 4.8
Functions
qcocoaintrospection_mac.mm File Reference
#include <private/qcocoaintrospection_p.h>

Go to the source code of this file.

Functions

void qt_cocoa_change_back_implementation (Class baseClass, SEL originalSel, SEL backupSel)
 
void qt_cocoa_change_implementation (Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
 

Function Documentation

◆ qt_cocoa_change_back_implementation()

void qt_cocoa_change_back_implementation ( Class  baseClass,
SEL  originalSel,
SEL  backupSel 
)

Definition at line 111 of file qcocoaintrospection_mac.mm.

Referenced by macStopInterceptNSPanelCtor(), and macStopInterceptWindowTitle().

112 {
113 #ifndef QT_MAC_USE_COCOA
115 #endif
116  {
117 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
118  Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
119  Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel);
120  method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass));
121 #endif
122  }
123 }
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646

◆ qt_cocoa_change_implementation()

void qt_cocoa_change_implementation ( Class  baseClass,
SEL  originalSel,
Class  proxyClass,
SEL  replacementSel,
SEL  backupSel 
)

Definition at line 80 of file qcocoaintrospection_mac.mm.

Referenced by macStartInterceptNSPanelCtor(), and macStartInterceptWindowTitle().

81 {
82 #ifndef QT_MAC_USE_COCOA
84 #endif
85  {
86 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
87  // The following code replaces the _implementation_ for the selector we want to hack
88  // (originalSel) with the implementation found in proxyClass. Then it creates
89  // a new 'backup' method inside baseClass containing the old, original,
90  // implementation (fakeSel). You can let the proxy implementation of originalSel
91  // call fakeSel if needed (similar approach to calling a super class implementation).
92  // fakeSel must also be implemented in proxyClass, as the signature is used
93  // as template for the method one we add into baseClass.
94  // NB: You will typically never create any instances of proxyClass; we use it
95  // only for stealing its contents and put it into baseClass.
96  if (!replacementSel)
97  replacementSel = originalSel;
98 
99  Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
100  Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel);
101  IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod));
102 
103  if (backupSel) {
104  Method backupMethod = class_getInstanceMethod(proxyClass, backupSel);
105  class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod));
106  }
107 #endif
108  }
109 }
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646