]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ole/activex.cpp
No changes, just use RAII-based classes in MSW owner drawn menu code.
[wxWidgets.git] / src / msw / ole / activex.cpp
index e2661bda65fe5dc78ad38ee0ec78a6afc417c133..71bbed04508a21acff9a1c54d5cf5fa5801423d0 100644 (file)
@@ -54,7 +54,7 @@ wxDEFINE_EVENT( wxEVT_ACTIVEX, wxActiveXEvent );
     {\
         public:\
         LONG l;\
-        TAutoInitInt() : l(0) {}\
+        TAutoInitInt() : l(1) {}\
     };\
     TAutoInitInt refCount, lockCount;\
     static void _GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc);\
@@ -1030,10 +1030,15 @@ void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
 
                 if ( cp )
                 {
-                    IDispatch* disp;
-                    m_frameSite->QueryInterface(IID_IDispatch, (void**)&disp);
-                    hret = cp->Advise(new wxActiveXEvents(this, ta->guid),
-                                      &adviseCookie);
+                    wxActiveXEvents * const
+                        events = new wxActiveXEvents(this, ta->guid);
+                    hret = cp->Advise(events, &adviseCookie);
+
+                    // We don't need this object any more and cp will keep a
+                    // reference to it if it needs it, i.e. if Advise()
+                    // succeeded.
+                    events->Release();
+
                     CHECK_HR(hret);
                 }
             }