Skip to content

Commit

Permalink
Add Qt destruction signal debugging helper
Browse files Browse the repository at this point in the history
  • Loading branch information
reingart committed Aug 1, 2014
1 parent 99b6fca commit b7ee2e8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/wx/qt/private/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ void wxMissingImplementation( const char fileName[], unsigned lineNumber,
#define wxMISSING_FUNCTION() \
wxMISSING_IMPLEMENTATION( __WXFUNCTION__ )

// global function handle Qt objects destruction (just for debugging now)
void wxQtHandleDestroyedSignal(QObject *qobj = 0);

#endif // _WX_QT_UTILS_H_
8 changes: 7 additions & 1 deletion include/wx/qt/private/winevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "wx/window.h"
#include "wx/qt/private/converter.h"
#include "wx/qt/private/utils.h"

#include <QtCore/QEvent>
#include <QtGui/QPaintEvent>
Expand Down Expand Up @@ -52,8 +53,12 @@ class wxQtEventSignalHandler : public Widget, public wxQtSignalHandler< Handler
{
// Set immediatelly as it is used to check if wxWindow is alive
wxWindow::QtStoreWindowPointer( this, handler );
}

// Handle QWidget destruction signal AFTER it gets deleted
QObject::connect( this, &QObject::destroyed, this,
&wxQtHandleDestroyedSignal );

}

virtual Handler *GetHandler() const
{
Expand Down Expand Up @@ -316,6 +321,7 @@ class wxQtEventSignalHandler : public Widget, public wxQtSignalHandler< Handler
virtual void tabletEvent ( QTabletEvent * event ) { }
virtual bool winEvent ( MSG * message, long * result ) { }
virtual bool x11Event ( XEvent * event ) { } */

};

#endif
7 changes: 7 additions & 0 deletions src/qt/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,10 @@ bool wxLaunchDefaultApplication(const wxString& path, int WXUNUSED( flags ) )
{
return QDesktopServices::openUrl( QUrl::fromLocalFile( wxQtConvertString( path ) ) );
}

// Generic "Slot" to conect destruction signal for debugging purposes:
void wxQtHandleDestroyedSignal(QObject *qobj)
{
wxLogDebug( wxT("%s was destroyed by Qt. pointer=%p"),
QObject::staticMetaObject.className(), qobj );
}

0 comments on commit b7ee2e8

Please sign in to comment.