Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

how to remove those compiler warnings

<< < (3/4) > >>

oBFusCATed:
ptDev: If it is not virtual how would you change the priority?
jarod42: This is an option, too, but someone should come up with a good name - always a hard task.

jarod42:

--- Code: ---virtual int getPriority() const { return 50; }
--- End code ---
or

--- Code: ---virtual void changePriority(int& priority) { priority = 50; }
--- End code ---

and then


--- Code: ---bool BuildToolBarAndSetPriority(wxToolBar* toolBar, int &priority)
{
  changePriority(priority);
  return BuildToolBar(toolBar);
}

--- End code ---

should be cleaner, I think.

ollydbg:
Some days later, I rethink it. Now. follow jarod42's advice
The code

--- Code: ---ToolbarInfo MainFrame::DoAddPluginToolbar(cbPlugin* plugin)
{
    ToolbarInfo info;
    info.toolbar = Manager::Get()->CreateEmptyToolbar();
    info.priority = 50;
    if (plugin->BuildToolBar(info.toolbar, info.priority))
    {
        SetToolBar(0);
        InitToolbar(info.toolbar);


--- End code ---
becomes like below:

In base class, add a function:

--- Code: ---virtual int GetToolBarPriority() { return 50; }

--- End code ---

If some derived plugin class need to implement some other priority values, they should override their own.


--- Code: ---ToolbarInfo MainFrame::DoAddPluginToolbar(cbPlugin* plugin)
{
    ToolbarInfo info;
    info.toolbar = Manager::Get()->CreateEmptyToolbar();
    //info.priority = 50;
    if (plugin->BuildToolbar(info.toolbar))
    {
        info.priority = plugin->GetToolBarPriority();
        SetToolBar(0);
        InitToolbar(info.toolbar);

--- End code ---

Is it right?

oBFusCATed:
Try it and see if it works...

ollydbg:

--- Quote from: oBFusCATed on June 15, 2012, 09:31:12 am ---Try it and see if it works...

--- End quote ---
I test it, and it works just fine.

Is the function name: GetToolBarPriority()  OK?

Ok to commit? (Include the change that remove the "virtual" keyword in operator=).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version