Page 1 of 1

Not receiving events

Posted: Fri Nov 14, 2008 12:39 am
by cenix
I want to subscribe to receive (the same) events as the BuildTab does for a NextBuildError.

Therefore I have made a class similar to the BuildTab (including de EVENT_TABLE and DECLARE_EVENT_TABLE).
I also call my class from Frame::OnNextBuildError(wxCommandEvent &event), yet I do not receive them.
Below is the code:

Header
========================

Code: Select all

class ErrorsTab : public OutputTabWindow {
{
...
public:
	DECLARE_EVENT_TABLE()
};
Implementation
========================

Code: Select all

#include "editor_config.h"
#include "precompiled_header.h"
#include "frame.h"
#include "wx/regex.h"
#include "buildtabsettingsdata.h"
#include "regex_processor.h"
#include "macros.h"
#include "wx/xrc/xmlres.h"
#include "build_settings_config.h"
#include "compiler.h"
#include "manager.h"
#include "project.h"
#include "wx/wxscintilla.h"
#include "errorstab.h"

#ifndef wxScintillaEventHandler
#define wxScintillaEventHandler(func) \
	(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxScintillaEventFunction, &func)
#endif

BEGIN_EVENT_TABLE(ErrorsTab, wxPanel)
	EVT_MENU(XRCID("next_error"), ErrorsTab::OnNextBuildError)
END_EVENT_TABLE()

rrorsTab::ErrorsTab(wxWindow *parent, wxWindowID id, const wxString &name)
		: OutputTabWindow(parent, id, name)
{
}

void ErrorsTab::OnNextBuildError(wxCommandEvent &event)
{
	wxUnusedVar(event);

	// do something
}
Implementation (Frame.cpp)
========================

Code: Select all

void Frame::OnNextBuildError(wxCommandEvent &event)
{
	GetOutputPane()->GetBuildTab()->ProcessEvent(event);
	GetOutputPane()->GetErrorsTab()->ProcessEvent(event);
}

Re: Not receiving events

Posted: Fri Nov 14, 2008 3:32 am
by eranif
2 things to try:

1) Try adding inside 'void BuildTab::OnNextBuildError(wxCommandEvent &event)' a call to event.Skip() replacing the wxUnusedVar(event);
2) What happen if you change the order? Is your handler get called?

Eran

Re: Not receiving events

Posted: Fri Nov 14, 2008 11:53 am
by cenix
When I change order I get exactly the same results. That I tried yesterday evening after posting this message.

As for 1. When I get back home and am able to do some coding, I'll try setting the event.Skip().

Re: Not receiving events

Posted: Fri Nov 14, 2008 10:24 pm
by cenix
Doing an event.Skip() makes CL running for crazy (an endless loop?)

However, it seems that it does receive events, since the OnNextBuildError does update the highlighted line, but a breakpoint in that method never fires.
I was debugging some stuff, but it's rather difficult to debug now.
[Edit]Ahh. wait, I was running a release version.. Trying to build debug now[/Edit]

Ohwell, seems other solutions need to be found.


Just out of curiosity: is there anything similar to OutputDebugString for Linux?

Re: Not receiving events

Posted: Fri Nov 14, 2008 10:30 pm
by eranif
Can I ask what are you trying to achieve?

Eran

Re: Not receiving events

Posted: Fri Nov 14, 2008 11:00 pm
by cenix
I'm trying to develop a errors/warnings dialog similar to that in MSVC.
In some projects, you do something wrong and get a load of errors/warnings.

It can be little hard to see them all in a glance. So I think it will improve error finding (next to the Next Build Error option of course).

Re: Not receiving events

Posted: Sat Nov 15, 2008 7:16 am
by sdolim
cenix wrote:Doing an event.Skip() makes CL running for crazy (an endless loop?)
This is because it's a command event. If you Skip() it in BuildTab, it propagates back up to Frame, which then passes it back to BuildTab. It might be better to Connect() the tabs (BuildTab and ErrorsTab) to wxTheApp to handle the "next_error" command. Then you can (and should) call Skip() in each tab's event handler.

Re: Not receiving events

Posted: Sat Nov 15, 2008 7:43 pm
by DavidGH
Hi,
Another alternative would be to use wxWindow::PushEventHandler to push ErrorsTab onto BuildTab. This will mean that the ErrorsTab instance receives the event and processes it. If it calls Skip(), the event will then be handled as normal by BuildTab. There wouldn't be any risk of recursion.

If you do this, you should remove the line GetOutputPane()->GetErrorsTab()->ProcessEvent(event); in Frame::OnNextBuildError.

Regards,

David

Re: Not receiving events

Posted: Sat Nov 15, 2008 11:32 pm
by cenix
I have it working now. Not exactly sure what the differences are, but I guess a compile error or something.
After I was able to successfully build and run a debug build, I saw the events coming in. Release build is now also working OK.

While building in debug, I had a number of compile time errors, that I did not have in release-mode builds. After resolving those errors all was fine.

Thanks for the help.