diff --git a/common/kiway.cpp b/common/kiway.cpp index 6031fe7bfa..56dff4a288 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -37,6 +37,7 @@ KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT]; int KIWAY::m_kiface_version[KIWAY_FACE_COUNT]; + KIWAY::KIWAY( PGM_BASE* aProgram, wxFrame* aTop ): m_program( aProgram ), m_top( 0 ) @@ -317,8 +318,7 @@ bool KIWAY::ProcessEvent( wxEvent& aEvent ) if( alive ) { -#if 0 - // This is still broken, but is the way to go. +#if 1 return alive->ProcessEvent( aEvent ); #else alive->KiwayMailIn( *mail ); diff --git a/common/kiway_express.cpp b/common/kiway_express.cpp index 230880421d..d11e6e7cee 100644 --- a/common/kiway_express.cpp +++ b/common/kiway_express.cpp @@ -27,7 +27,18 @@ //IMPLEMENT_DYNAMIC_CLASS( KIWAY_EXPRESS, wxEvent ) +#if 0 // requires that this code reside in only a single link image, rather than + // in each of kicad.exe, _pcbnew.kiface, and _eeschema.kiface as now. + // In the current case wxEVENT_ID will get a different value in each link + // image. We need to put this into a shared library for common utilization, + // I think that library should be libki.so. I am reluctant to do that now + // because the cost will be finding libki.so at runtime, and we need infrastructure + // to set our LIB_ENV_VAR to the proper place so libki.so can be reliably found. + // All things in due course. const wxEventType KIWAY_EXPRESS::wxEVENT_ID = wxNewEventType(); +#else +const wxEventType KIWAY_EXPRESS::wxEVENT_ID = 30000; // commmon accross all link images, hopefully unique. +#endif KIWAY_EXPRESS::KIWAY_EXPRESS( const KIWAY_EXPRESS& anOther ) : diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index 4706aac339..427fdf3a51 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -8,7 +8,9 @@ BEGIN_EVENT_TABLE( KIWAY_PLAYER, EDA_BASE_FRAME ) /* have not been able to get this to work yet: EVT_KIWAY_EXPRESS( KIWAY_PLAYER::kiway_express ) - Use Connect() in constructor until this can be sorted out + Use Connect() in constructor until this can be sorted out. + + OK the problem is KIWAY_PLAYER::wxEVENT_ID not being unique accross all link images. */ END_EVENT_TABLE() diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 102b3ff18f..b8bd39884a 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -176,19 +177,27 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aComponent, SCH_COMPONENT* a SendCommand( MSG_TO_PCB, packet.c_str() ); else { - Kiway().ExpressMail( FRAME_PCB, 0, packet, this ); + // Typically ExpressMail is going to be s-expression packets, but since + // we have existing interpreter of the cross probe packet on the other + // side in place, we use that here. + Kiway().ExpressMail( FRAME_PCB, MAIL_CROSS_PROBE, packet, this ); } } } -#include - void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) { - // @todo switch on command type - std::string payload = mail.GetPayload(); + const std::string& payload = mail.GetPayload(); - ExecuteRemoteCommand( payload.c_str() ); + switch( mail.Command() ) + { + case MAIL_CROSS_PROBE: + ExecuteRemoteCommand( payload.c_str() ); + break; + + // many many others. + + } } diff --git a/include/kiway_express.h b/include/kiway_express.h index 6e95d5ae39..e331f3fcb9 100644 --- a/include/kiway_express.h +++ b/include/kiway_express.h @@ -29,6 +29,20 @@ #include #include + +/** + * Enum MAIL_T + * is the set of mail types sendable via KIWAY::ExpressMail() and supplied as + * the @a aCommand parameter to that function. Such mail will be received in + * KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent ) and aEvent.Command() will + * match aCommand to ExpressMail(). + */ +enum MAIL_T +{ + MAIL_CROSS_PROBE, +}; + + /** * Class KIWAY_EXPRESS * carries a payload from one KIWAY_PLAYER to anothing within a PROJECT. @@ -42,6 +56,15 @@ public: */ FRAME_T Dest() { return m_destination; } + /** + * Function Command + * returns the EXPRESS_MAIL_T associated with this mail. + */ + MAIL_T Command() + { + return (MAIL_T) GetId(); // re-purposed control id. + } + /** * Function Payload * returns the payload, which can be any text but it typicall self diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index bb119edf23..05f12dc766 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -206,19 +207,27 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* aSyncItem ) SendCommand( MSG_TO_SCH, packet.c_str() ); else { - Kiway().ExpressMail( FRAME_SCH, 0, packet, this ); + // Typically ExpressMail is going to be s-expression packets, but since + // we have existing interpreter of the cross probe packet on the other + // side in place, we use that here. + Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this ); } } } -#include - void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) { - // @todo switch on command type - std::string payload = mail.GetPayload(); + const std::string& payload = mail.GetPayload(); - ExecuteRemoteCommand( payload.c_str() ); + switch( mail.Command() ) + { + case MAIL_CROSS_PROBE: + ExecuteRemoteCommand( payload.c_str() ); + break; + + // many many others. + + } }