Author Topic: a Qt plugin : QtPregenForCB => AddOnForQt  (Read 130622 times)

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
a Qt plugin : QtPregenForCB => AddOnForQt
« on: February 10, 2015, 05:53:03 pm »
From January 01, 2020, 'Qtpregen' will be replaced by 'Addonforqt'
http://forums.codeblocks.org/index.php/topic,20000.msg165730.html#msg165730

Hello everyone,
I suggest a plugin for compiling Qt project using Code::Blocks .
This extension of  Code::Blocks will be offered on:
https://github.com/LETARTARE/QtPregenForCB
and is called :
Quote
QtPregenForCB-0.2.2

If this plugin interested persons, I would do an article in the Wiki.

See the discussion: http://forums.codeblocks.org/index.php/topic,19931.0.html
Sincerely
« Last Edit: December 28, 2020, 01:20:54 am by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #1 on: February 11, 2015, 09:20:32 am »
Hello,
I forgot to provide patches for 'Code::Blocks'  (svn 9501, 10035, 10091)  !!
It is repaired.
https://github.com/LETARTARE/QtPregenForCB
Sincerely
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: a new plugin : QtPregenForCB
« Reply #2 on: February 11, 2015, 06:30:55 pm »
I forgot to provide patches for 'Code::Blocks'  (svn 9501, 10035, 10091)  !!
...in SVN. I see no reason why we should not do this. However, keep the comments of obfuscated in mind... To be bullet-proof the event ID's should be standardised and exposed through the SDK. So this actually is only half of the way...
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #3 on: February 11, 2015, 09:03:49 pm »
I still don't think this is a good solution, in fact I think this is terrible solution and if it was up to me I'd revert it.

For example the current version of the plugin will break if the user uses the context menu in the project manager.
It will break, if the compilation is started by a script. Or even from the debugger.

If you need to know something like a reason why the event has been fired then we should use some kind enum for the task.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: a new plugin : QtPregenForCB
« Reply #4 on: February 11, 2015, 09:40:13 pm »
If you need to know something like a reason why the event has been fired then we should use some kind enum for the task.
Thats what I meant with:
To be bullet-proof the event ID's should be standardised and exposed through the SDK.
However, in the compiler you'd then only replace the int ID with an enum ID. Therefore the code is "kind of" valid. I didn't state that its correct to use the ID's as done in the plugin.
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #5 on: February 11, 2015, 11:51:10 pm »
But still how do you know that the value of the m_EventId is set correctly before we the event is fired?
There is no code to reset it. So if the event is fired from a different code-path than the one expected it will be fired with invalid information.

Shouldn't we add more fine grained events that make the implementation of this plugin possible?

From the code of the plugin I can see that it is interested to know if a project is cleaned, built or if a single file is compiled (but does nothing in this case).

Should I revert this commit or you'll do it?  8)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #6 on: February 12, 2015, 07:01:06 pm »
Hello,
thank you very much to both of you for your advice.
@MortenMacFly
Thanks for the commit to svn 10115  :)

@oBFusCATed
I'm not sure I understood ?
Quote
For example the current version of the plugin will break if the user uses the context menu in the project manager.
because actually I can use the context menu 'Build, Rebuild, Clean' with no break.

Quote
From the code of the plugin I can see that it is interested to know if a project is cleaned, built or if a single file is compiled (but does nothing in this case).
Yes, it is exactly that. For a single file I still wonder about the work to be done?

Anyway, if you have a different solution, with the current svn, I take.

Another question:
Is it possible to use the 'Build log' to display messages generated by the pre-generate ?
This would be more consistent than display them in 'Code::Blocks log'.

Sincerely.
« Last Edit: February 12, 2015, 07:05:01 pm by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #7 on: February 12, 2015, 07:19:16 pm »
because actually I can use the context menu 'Build, Rebuild, Clean' with no break.
I doubt, because they have different ids, as far as I can see.
Have you tried to use them just after you've started a fresh instance of C::B?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #8 on: February 12, 2015, 07:26:55 pm »
I'll try because I am trying to compile svn 10116...
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #9 on: February 12, 2015, 07:35:55 pm »
I confim...
I use svn 10116, rebuilt the plugin and context menus work correctly.
I'll check id's for safety ...
'QtPregenForCB' must be loaded after 'CompilerGcc',  but that's always the case !
I did a test by changing the name of the plugin 'CbqtPregen', and there the id's become -1!
« Last Edit: February 23, 2015, 07:53:54 pm by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #10 on: February 12, 2015, 08:05:32 pm »
I can believe you. There is no chance for this to work.
This is the code that registers the context menu items. Obviously the items don't reuse the ids from the main menu.
And I couldn't see any code that takes these ids.
Code
        menu->Append(idMenuCompileFromProjectManager, _("Build"));
        menu->Append(idMenuRebuildFromProjectManager, _("Rebuild"));
        menu->Append(idMenuCleanFromProjectManager,   _("Clean"));

The dependence on the plugin load order is another nail in the coffin of this change!  8)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #11 on: February 12, 2015, 08:13:55 pm »
If you need to make a robust solution.
Take a look at the CompilerGCC::BuildStateManagement function. There is a switch for every build action.
You can invent an event that fires in this specific moment so it will always be correct.
You can add events that fire at the end of the action. So you will know when clean has started and also you'll know when it has finished. Also you'll know the same things about the other phases of the build.

Also there are the cbEVT_CLEAN_PROJECT_STARTED and cbEVT_CLEAN_WORKSPACE_STARTED events.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #12 on: February 12, 2015, 11:13:34 pm »
I ask that you check, you'll see!

For
Code
 menu->Append(idMenuCompileFromProjectManager, _("Build"));
menu->Append(idMenuRebuildFromProjectManager, _("Rebuild"));
menu->Append(idMenuCleanFromProjectManager,   _("Clean"));

A little higher in the Dispatcher:

Code
void CompilerGCC::Dispatcher(wxCommandEvent& event)
{
    m_EventId = event.GetId();
//    Manager::Get()->GetMessageManager()->Log(wxT("Dispatcher")));
    if (m_EventId == idMenuRun)
        OnRun(event);
    else if (m_EventId == idMenuCompileAndRun)
        OnCompileAndRun(event);
    else if (m_EventId == idMenuCompile)
        OnCompile(event);
    else if (m_EventId == idMenuCompileFromProjectManager)
        OnCompile(event);
    else if (m_EventId == idMenuCompileFile)
        OnCompileFile(event);
    else if (m_EventId == idMenuCompileFileFromProjectManager)
        OnCompileFile(event);
    else if (m_EventId == idMenuCleanFileFromProjectManager)
        OnCleanFile(event);
    else if (m_EventId == idMenuRebuild)
        OnRebuild(event);
    else if (m_EventId == idMenuRebuildFromProjectManager)
        OnRebuild(event);
....

we recover the same id's
Quote
idMenuCompileFromProjectManager
idMenuCleanFileFromProjectManager
idMenuRebuildFromProjectManager
triggers
Quote
OnCompile(event);
OnRebuild(event);

Quote
Take a look at the CompilerGCC::BuildStateManagement function.
I will try to understand how it works to use.
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #13 on: February 13, 2015, 12:10:03 am »
I don't understand what you mean with the last post.
Do you agree that there is no chance for your plugin to work correctly when someone is using the context menu or are you seeing something in the code that I'm missing?

I ask that you check, you'll see!
I don't understand the meaning of this sentence.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #14 on: February 13, 2015, 09:20:55 am »
I ask you to try the plugin 'QtPregenForCB' to verify that the context menu works correctly.
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl