Hey Wim,
2013/12/31 Wim Dumon <w...@emweb.be>
> Hello Dmitriy,
>
> Thank you for reporting the WMenuItem bug, this is my fix:
> if (contents_) {
> // contents' ownership will be moved to a containerwidget once
> // it is in the widget tree (contentsLoaded). In any case, if
> // contents_ is destroyed elsewhere, we want to know about it.
> contentsDestroyedConnection_ =
> contents_->destroyed().connect(this, &WMenuItem::contentsDestroyed);
> }
>
Yes, this fixes the regression.
>
>
> With this fix, and with the following little modification to your example
> program, I think the behaviour is as expected?
> WMenu* const m = new WMenu(new WStackedWidget(root()));
>
This fixes error in my test case :-)
But the test case in the attachment demonstrates another bug -- it's
about incorrect internal path handling by WMenu (when the user uses
submenus which participates in the internal path handling). Please,
see the attachment.
--
// Dmitriy.
// -*- C++ -*-
//
// (C) 2013 Dmitry Igrishin
//
// Bug report.
// Description: incorrect WMenu internal path handling for submenu items.
// How to reproduce:
// 1) Open URL: host (or host/search)
// (works as expected)
// 2) Open URL: host/settings
// (OOPS, submenu does not handle internal path at all since
// unnecessary check -- if (!parentItem_) in
// WMenu::handleInternalPathChange(const std::string&))
#include <Wt/WApplication>
#include <Wt/WMenu>
#include <Wt/WMenuItem>
#include <Wt/WPopupMenu>
#include <Wt/WStackedWidget>
#include <Wt/WText>
using namespace Wt;
namespace {
class App : public WApplication {
public:
App(const WEnvironment& e);
private:
WMenu*
make_menu();
WPopupMenu*
make_submenu(WStackedWidget*);
WMenu* menu_;
};
App::App(const WEnvironment& e)
: WApplication(e)
{
root()->addWidget(make_menu());
}
WMenu*
App::make_menu()
{
WMenu* const m = new WMenu(new WStackedWidget(root()));
m->setInternalPathEnabled("/");
WMenuItem* mi = new WMenuItem("Search", new WText("Search page"));
mi->setInternalPathEnabled(true);
mi->setPathComponent("search");
m->addItem(mi);
// Submenu "More"
mi = new WMenuItem("More"); // Item only for grouping, but submenu
// will participate in the internal path...
mi->setInternalPathEnabled(false);
mi->setMenu(make_submenu(m->contentsStack()));
m->addItem(mi);
return m;
}
WPopupMenu*
App::make_submenu(WStackedWidget* const contents)
{
WPopupMenu* const m = new WPopupMenu(contents);
m->setInternalPathEnabled("/");
WMenuItem* const mi = new WMenuItem("Settings", new WText("Settings page"));
mi->setInternalPathEnabled(true);
mi->setPathComponent("settings");
m->addItem(mi);
return m;
}
WApplication*
create_app(const WEnvironment& env)
{
return new App(env);
}
} // namespace
int
main(int argc, char* argv[])
{
return WRun(argc, argv, create_app);
}
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest