Not receiving events

CodeLite installation/troubleshooting forum
cenix
CodeLite Enthusiast
Posts: 20
Joined: Wed Sep 24, 2008 9:49 pm

Not receiving events

Post by cenix » Fri Nov 14, 2008 12:39 am

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);
}

User avatar
eranif
CodeLite Plugin
Posts: 6110
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Not receiving events

Post by eranif » Fri Nov 14, 2008 3:32 am

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
Make sure you have read the HOW TO POST thread

cenix
CodeLite Enthusiast
Posts: 20
Joined: Wed Sep 24, 2008 9:49 pm

Re: Not receiving events

Post by cenix » Fri Nov 14, 2008 11:53 am

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().

cenix
CodeLite Enthusiast
Posts: 20
Joined: Wed Sep 24, 2008 9:49 pm

Re: Not receiving events

Post by cenix » Fri Nov 14, 2008 10:24 pm

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?

User avatar
eranif
CodeLite Plugin
Posts: 6110
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Not receiving events

Post by eranif » Fri Nov 14, 2008 10:30 pm

Can I ask what are you trying to achieve?

Eran
Make sure you have read the HOW TO POST thread

cenix
CodeLite Enthusiast
Posts: 20
Joined: Wed Sep 24, 2008 9:49 pm

Re: Not receiving events

Post by cenix » Fri Nov 14, 2008 11:00 pm

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).

sdolim
CodeLite Veteran
Posts: 69
Joined: Fri Oct 24, 2008 10:29 pm
Contact:

Re: Not receiving events

Post by sdolim » Sat Nov 15, 2008 7:16 am

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.

DavidGH
CodeLite Plugin
Posts: 676
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: Not receiving events

Post by DavidGH » Sat Nov 15, 2008 7:43 pm

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

cenix
CodeLite Enthusiast
Posts: 20
Joined: Wed Sep 24, 2008 9:49 pm

Re: Not receiving events

Post by cenix » Sat Nov 15, 2008 11:32 pm

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.

Post Reply