Author Topic: fixing EVT_PROJECT_OPEN  (Read 18077 times)

Offline pauliusz

  • Multiple posting newcomer
  • *
  • Posts: 73
fixing EVT_PROJECT_OPEN
« on: June 27, 2007, 11:39:03 pm »
Problem: Currently EVT_PROJECT_OPEN event is generated in "wrong" place... (Bug #11233)

Reason: EVT_PROJECT_OPEN event was moved to "wrong" place in revision 1437 (long long time ago), because there were problems with code-completion(CC).

Solution: Since CC doesn't use EVT_PROJECT_OPEN anymore it is safe to move it back to "right" place.

I could do this by myself, but I not sure about all these "new" protections if workspace is loading...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: fixing EVT_PROJECT_OPEN
« Reply #1 on: June 28, 2007, 01:53:54 am »
And what's the "right place"?  :?

Offline pauliusz

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: fixing EVT_PROJECT_OPEN
« Reply #2 on: June 28, 2007, 09:06:24 am »
And what's the "right place"?  :?
You can see it in the change log of revision 1437.
You can also see it if you will search files for EVT_PROJECT_OPEN.

Offline dje

  • Lives here!
  • ****
  • Posts: 682
Re: fixing EVT_PROJECT_OPEN
« Reply #3 on: June 28, 2007, 10:33:57 am »
Hi !

Quote
You can see it in the change log of revision 1437.
You can also see it if you will search files for EVT_PROJECT_OPEN.

Far easier than giving file/method/line in current version  :wink:

Dje

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: fixing EVT_PROJECT_OPEN
« Reply #4 on: June 28, 2007, 12:07:16 pm »
Is it really necessary to change yet another core behaviour without urgent need at this time?

I can't tell beforehand what effects this particular change will have, but I can tell what effect the last few had.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline pauliusz

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: fixing EVT_PROJECT_OPEN
« Reply #5 on: June 28, 2007, 12:52:44 pm »
Is it really necessary to change yet another core behaviour without urgent need at this time?

I think Pecan could give some comments about that.

Quote
I can't tell beforehand what effects this particular change will have, but I can tell what effect the last few had.

I have looked at placed where EVT_PROJECT_OPEN is used and it looks like there shouldn't be any problems. But I'm not 100% sure :)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2873
Re: fixing EVT_PROJECT_OPEN
« Reply #6 on: June 28, 2007, 01:14:41 pm »
Is it really necessary to change yet another core behaviour without urgent need at this time?

I can't tell beforehand what effects this particular change will have, but I can tell what effect the last few had.

I believe it should be corrected before an sdk release.

I've had to rely on using the project hooks instead of the cbEvents for plugins.

As it is now, editor activation and project activation events occur before project open events.

This really screws with the maintenance of dynamic arrays holding objects or pointers to editors.

If a release of the sdk goes out with this problem, plugin writers can never rely on these cbEvents.
We'll just have to tell them to use the Project and Editor hooks instead. Much more overhead.

I'll write up a simple plugin today to show the problem.

« Last Edit: June 28, 2007, 01:17:11 pm by Pecan »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: fixing EVT_PROJECT_OPEN
« Reply #7 on: June 28, 2007, 03:58:27 pm »
Pecan, you could also use EVT_WORKSPACE_CHANGED, I put it there *EXACTLY* for that reason. When the new project has finished opening, the EVT_WORKSPACE_CHANGED is triggered. Perhaps you could use it in combination with EVT_PROJECT_OPEN..
« Last Edit: June 28, 2007, 04:00:09 pm by rickg22 »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2873
Re: fixing EVT_PROJECT_OPEN
« Reply #8 on: June 28, 2007, 04:36:06 pm »
Pecan, you could also use EVT_WORKSPACE_CHANGED, I put it there *EXACTLY* for that reason. When the new project has finished opening, the EVT_WORKSPACE_CHANGED is triggered. Perhaps you could use it in combination with EVT_PROJECT_OPEN..

Sorry, that won't work. Here's why:
The sequence of events when loading a project:

Code
Loading a project

10:34:55: [1419125ms] EVT_EDITOR_DEACTIVATED [050C8B18][]
10:34:55: [1419125ms] EVT_EDITOR_ACTIVATED [050C8B18][]
10:34:55: [1419172ms] EVT_EDITOR_OPEN [050C8B18][EventsDisplay.cpp]

10:34:55: [1419187ms] EVT_EDITOR_DEACTIVATED [028EDA58][]
10:34:55: [1419187ms] EVT_EDITOR_ACTIVATED [028EDA58][]
10:34:55: [1419219ms] EVT_EDITOR_OPEN [028EDA58][EventsDisplay.h]

10:34:55: [1419234ms] EVT_EDITOR_DEACTIVATED [050C8B18][EventsDisplay.cpp]
10:34:55: [1419234ms] EVT_EDITOR_ACTIVATED [050C8B18][EventsDisplay.cpp]
10:34:55: [1419234ms] EVT_EDITOR_ACTIVATED [050C8B18][EventsDisplay.cpp]

10:34:55: [1419266ms] EVT_PROJECT_ACTIVATE[]
10:34:55: [1419266ms] EVT_PROJECT_OPEN
10:34:55: [1419266ms] EVT_EDITOR_DEACTIVATED [050C8B18][EventsDisplay.cpp]
10:34:55: [1419266ms] EVT_EDITOR_ACTIVATED [050C8B18][EventsDisplay.cpp]
10:34:55: [1419281ms] EVT_WORKSPACE_CHANGED[]
10:34:55: [1419281ms] EVT_WORKSPACE_CHANGED[]

 Now closing the project
 
10:35:10: [1433953ms] EVT_PROJECT_CLOSE[]
10:35:10: [1433953ms] EVT_EDITOR_DEACTIVATED [05095BA8][]
10:35:10: [1433953ms] EVT_EDITOR_ACTIVATED [05095BA8][]
10:35:10: [1434062ms] EVT_EDITOR_CLOSE [050C8B18][unavailable]
10:35:10: [1434078ms] EVT_EDITOR_DEACTIVATED [05095BA8][Start here]
10:35:10: [1434094ms] EVT_EDITOR_ACTIVATED [05095BA8][Start here]
10:35:10: [1434094ms] EVT_EDITOR_CLOSE [028EDA58][unavailable]
10:35:10: [1434109ms] EVT_EDITOR_DEACTIVATED [05095BA8][Start here]
10:35:10: [1434109ms] EVT_EDITOR_ACTIVATED [05095BA8][Start here]
10:35:10: [1434125ms] EVT_WORKSPACE_CHANGED[]
10:35:10: [1434125ms] EVT_WORKSPACE_CHANGED[]

If you used EVT_WORKSPACE_CHANGED, you'd miss every open/activate on every editor.
If you wanted to wait until a project opened, you again would miss every editor.

The whole sequence is backwards. OR... I'm misunderstanding the purpose of the events.


http://www.savefile.com/files/848388


Above is a url containing cbEventsDisplay.zip with source and .cbplugin for MSW .
Use Plugins/Manage Plugsin/Install new/ to install and remove it.

It'll open up a log in the upper left and log the events as they occur.

 
« Last Edit: June 28, 2007, 06:57:59 pm by Pecan »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: fixing EVT_PROJECT_OPEN
« Reply #9 on: June 28, 2007, 05:40:24 pm »
Well, I'm suggesting a workaround. Try adding a queue to your plugin.

Like
Code
OnEditorActivate(...)
{
  if(ProjectManager::IsBusy())
     m_filequeue.insert(theeditor);
  else
     do_stuff_on_editor(theeditor);
}

OnEditorDeActivate(...)
{
  if(ProjectManager::IsBusy())
     m_filequeue.erase(theeditor);
  else
     undo_stuff_on_editor(theeditor);
}

OnWorkspaceChanged...
{
  Do_stuff_on_filequeue();
  filequeue.clear();
}
Since I don't really know what you're doing, I can't suggest a specific method, but what I do goes around those lines.

But yes, I agree that in this case, the PROJECT_OPEN should be triggered before.

The problem is WHAT WE WANT the events for.

Should we have a PROJECT_BEGIN_OPENING and PROJECT_FINISHED_OPENING events?

In any case, PROJECT_OPEN should go immediately *BEFORE* PROJECT_ACTIVATE. And PROJECT_CLOSE should go immediately *AFTER* PROJECT_DEACTIVATE for the events to have some coherence.

The real question is, if by doing this, we break existing functionality on the plugins.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: fixing EVT_PROJECT_OPEN
« Reply #10 on: June 28, 2007, 05:46:42 pm »

Code
10:35:10: [1434125ms] EVT_WORKSPACE_CHANGED[] 
10:35:10: [1434125ms] EVT_WORKSPACE_CHANGED[]

WHOA! That EVT_WORKSPACE_CHANGED should only happen once!  :shock:
I need to look into that...

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2873
Re: fixing EVT_PROJECT_OPEN
« Reply #11 on: June 28, 2007, 06:07:41 pm »
Well, I'm suggesting a workaround. Try adding a queue to your plugin.

Yes, I have plenty of workarounds. The best of which is to simply use the editor/project hooks. They occur in the correct order.

Just thought it'd be nice to actually have a SDK that's dependable.

But if not... we'll learn and use the hack-arounds.


Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: fixing EVT_PROJECT_OPEN
« Reply #12 on: June 28, 2007, 08:37:14 pm »

Code
10:35:10: [1434125ms] EVT_WORKSPACE_CHANGED[] 
10:35:10: [1434125ms] EVT_WORKSPACE_CHANGED[]

WHOA! That EVT_WORKSPACE_CHANGED should only happen once!  :shock:
I need to look into that...

This is a long known condition (see the other thread). It happens for several events.
PLEASE do not add another workaround for this.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: fixing EVT_PROJECT_OPEN
« Reply #13 on: June 28, 2007, 09:01:30 pm »
This is a long known condition (see the other thread). It happens for several events.
PLEASE do not add another workaround for this.

What other thread?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ