Author Topic: When is Configure() called??  (Read 10228 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2770
When is Configure() called??
« on: October 23, 2005, 09:29:31 pm »
Why doesn't the following code in a plugin crash??
I'm running C::B 1.0RC1.1 and compiling with a wx242 DLL
WinXPsp2.

I never got a message box, so I inserted the INT3.
I don't get a message OR a crash.

I'm feeling ignored by my plugin. :lol:


int Untitled1::Configure()
{
    // if not attached, exit
//    if (!m_IsAttached)
//        return -1;
    asm("int3");
      wxString msg = _("Configure called!");
      wxMessageBox(msg, _("Error"), wxICON_ERROR | wxOK);
    return 0;
}

Thanks

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: When is Configure() called??
« Reply #1 on: October 23, 2005, 09:32:50 pm »
Code
Untitled1::Untitled1
{
...
m_PluginInfo.hasConfigure = true;
...
}

Then go to Settings --> Plugins' Settings --> Untitled1
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2770
Re: When is Configure() called??
« Reply #2 on: October 23, 2005, 09:38:25 pm »
Thankyou, I can crash now.  :)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: When is Configure() called??
« Reply #3 on: October 23, 2005, 09:46:42 pm »
Lol, I try to avoid that ;)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2770
Re: When is Configure() called??
« Reply #4 on: October 23, 2005, 10:06:13 pm »
wups! I failed to notice that I already had m_PluginInfo.hasConfigure = true;   in the ctor. I still can't crash.

Just goes to show, when ya wanna, ya can't.

Have I done something wrong in generating my wx 2.4.2 DLL??
Do I have an alien C::B??
I get the "Hello Code::Blocks" but no crash and no Configure() message.
I also noticed that when I compile other plugins, their Configure() doesnt
get executed either.

Could you point my nose the the right direction?

bPlugin* GetPlugin()
{
   return new Untitled1;
}

Untitled1::Untitled1()
{
   //ctor
   m_PluginInfo.name = "UPlgN1";
   m_PluginInfo.title = "uPlgN1";
   m_PluginInfo.version = "1";
   m_PluginInfo.description = "Mispent Intent";
   m_PluginInfo.author = "Pecan";
   m_PluginInfo.authorEmail = "";
   m_PluginInfo.authorWebsite = "";
   m_PluginInfo.thanksTo = "Code::Blocks Team";
   m_PluginInfo.license = LICENSE_GPL;
   //-m_PluginInfo.hasConfigure = false;
   m_PluginInfo.hasConfigure = true;
}

Untitled1::~Untitled1()
{
   //dtor
   
}
int Untitled1::Configure()
{
    // if not attached, exit
//    if (!m_IsAttached)
//        return -1;
    asm("int3");
      wxString msg = _("Configure called!");
      wxMessageBox(msg, _("Error"), wxICON_ERROR | wxOK);
    return 0;
}

void Untitled1::OnAttach()
{
   // do whatever initialization you need for your plugin
   // NOTE: after this function, the inherited member variable
   // m_IsAttached will be TRUE...
   // You should check for it in other functions, because if it
   // is FALSE, it means that the application did *not* "load"
   // (see: does not need) this plugin...
}

void Untitled1::OnRelease(bool appShutDown)
{
   // do de-initialization for your plugin
   // if appShutDown is false, the plugin is unloaded because Code::Blocks is being shut down,
   // which means you must not use any of the SDK Managers
   // NOTE: after this function, the inherited member variable
   // m_IsAttached will be FALSE...
}

int Untitled1::Execute()
{
   //do your magic ;)
   //NotImplemented("Untitled1::Execute()");
   //return -1;
   if( !IsAttached() )
     return -1;
    Manager::Get()->GetMessageManager()->Log( _("Hello World!") );
    wxString msg = _("Hello Code::Blocks!");
    wxMessageBox(msg, _("Error"), wxICON_ERROR | wxOK);

    return 0;
 
}


Thanks

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: When is Configure() called??
« Reply #5 on: October 23, 2005, 10:15:51 pm »
Can't see anything wrong there at first sight (from RC2 on, you should replace the GetPlugin function with a new macro found in the SDK, but for the time being, that's fine).

Do you have __GNUWIN32__ WXUSINGDLL BUILDING_PLUGIN defined as compiler options?

And (very obvious thing) do you have the plugin copied to the plugins folder and enabled it in plugins settings?

What happens if you move the INT 3 into the constructor, does that crash the application on startup?


EDIT:
As a sidenote, wxBell(); will let you know that something happened, too, and is a little less intrusive than INT 3 ;)
« Last Edit: October 23, 2005, 10:25:47 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2770
Re: When is Configure() called??
« Reply #6 on: October 23, 2005, 10:46:53 pm »
Sure enough. Moving the INT3 into the ctor crashes like
an 80 year old after .... never mind.

So.. your idea about compiler options. Its gotta be there somewhere.
The project's at c:\usr\proj\uPlgN1\*.*

Cutting and pasting options:

[compiler->#defines]
__GNUWIN32__
WXUSINGDLL
BUILDING_PLUGIN

[Linker]
codeblocks
wxmsw242

[Directories/Compiler]
c:\usr\proj\wxWidgets242\contrib\include
c:\usr\proj\wxWidgets242\include
c:\usr\proj\wxWidgets242\lib\mswdll
c:\Usr\CodeBlocks\SDK\include

[Directories/Linker]
..\wxWidgets242\lib  <--this is c:\usr\proj\wxWidgets242\lib (wxmsw242.dll)
c:\usr\codeblocks     <-- (codeblocks.dll)

[Resource Compiler]
..\wxWidgets242\include  <--this is c:\usr\proj\wxWidgets242\include

Actually I'm still confused about where to point those
Directory entries. I just did it until the errors went away.

I'll take any advice anytime, anyhow

Thanks

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: When is Configure() called??
« Reply #7 on: October 23, 2005, 11:00:25 pm »
Except for this...
[Directories/Linker]
..\wxWidgets242\lib  <--this is c:\usr\proj\wxWidgets242\lib (wxmsw242.dll)
c:\usr\codeblocks     <-- (codeblocks.dll)
...everything looks (as far as I can see) just like it worked fine for me all the time (just switched to wx2.6).

I would give it a try with <codeblocks dir>\lib instead of ..\wxWidgets242\lib, except for that I don't see anything at this time, sorry.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: When is Configure() called??
« Reply #8 on: October 23, 2005, 11:02:30 pm »
What *exactly* are you doing to crash it? Configure() is called when the relevant menu entry is selected in "Settings->Plugins' settings->[your plugin name]". Do you select that menu entry?
Be patient!
This bug will be fixed soon...

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2770
Re: When is Configure() called??
« Reply #9 on: October 23, 2005, 11:33:24 pm »
Hi mandrav

The problem is that Untitled::Configure() *won't* crash because it never
gets called. We know that the ctor is being called because we *can* crash it
with and INT3. Using an INT3 hammer where a wxBell would do.

Anyway, ::Execute() works fine. I get a messagebox from it when I click
on Plusgins->uPlgN1. Somehow C::B is never seeing my      "m_PluginInfo.hasConfigure = true;" even tho we know it's being executed. i.e. put an INT3 in front of it and it crashes.

So, I'm looking for a header or linker conflict. I'm guessing... I'm wishing..
I'm hopping for luck..

It's me vs C::B, and C::B is winning. (so far). But I aint done yet...

I compared ..\SDK\include with ..\SDK\codeblocks-1.0-RC1-1_sdk\include\
the only difference is ..\SDK\include contains cdEditor.h while ..\SDK\codeblocks-1.0-RC1-1_sdk\include\ does not. But I dont know which was used by the build yet.

Im working on it.... If you come up with any ideas, I'll try 'em out

Thanks
« Last Edit: October 23, 2005, 11:34:57 pm by Pecan »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: When is Configure() called??
« Reply #10 on: October 23, 2005, 11:54:09 pm »
What Yiannis was asking was whether you actually do this:
Then go to Settings --> Plugins' Settings --> Untitled1

If Execute() really works, then it is most likely that message passing is ok, because both functions are invoked using the same mechanism.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2770
Re: When is Configure() called??
« Reply #11 on: October 24, 2005, 12:13:55 am »
Ahhhhh, s@#t!!!! That's it!!.

Ya know, my right brain is amazed at how dense my left brain is.
I'm embarrased.

Sorry to have done that to you guys.  I should have read the documentation.
Or at least walked the menu.

Thanks for putting up with me

Pecan