Hi,
I found the cause of the crash. Within our Wt app we wanted to use the
WIconPair class. But with a sligthly modified WImage class. Therefore I
copied the WIconPair to WImagePair which gets just already created
WImage objects.
The custom Image class adds support for showing a disabled (grey'd icon)!
Adding a WImagePair object to a layout manager results in the previous
mentioned core dump!
I have attached the apropriate sources.
class LeftViewShowImage : public Image
{
public:
LeftViewShowImage(const Wt::WString& tooltip)
: Image(tooltip,
Wt::WLink(Wt::WApplication::resourcesUrl() +
"icons/leftviewshow.png"),
Wt::WLink(Wt::WApplication::resourcesUrl() +
"icons/leftviewshow_d.png"),
16, 16) {}
};
class LeftViewHideImage : public Image
{
public:
LeftViewHideImage(const Wt::WString& tooltip)
: Image(tooltip,
Wt::WLink(Wt::WApplication::resourcesUrl() +
"icons/leftviewhide.png"),
Wt::WLink(Wt::WApplication::resourcesUrl() +
"icons/leftviewhide_d.png"),
16, 16) {}
};
mToggleLeftView =
new WImagePair(new LeftViewHideImage(WString::tr("leftview-hide-text")),
new LeftViewShowImage(WString::tr("leftview-show-text")));
mToggleLeftView->icon1Clicked().connect(this, &Browser::toggleLeftView);
mToggleLeftView->icon2Clicked().connect(this, &Browser::toggleLeftView);
HBoxLayout* hbox1 = new WHBoxLayout();
adding this widget to a layout causes the crash!
====> hbox1->addWidget(mToggleLeftView);
Any idea?
Regards,
Stefan
Am 22.02.2013 10:53, schrieb Stefan Ruppert:
Hi all,
I'm currently trying to upgrade to Wt 3.3.0 from Wt 3.2.3. Compiling
just went fine. But during initialization I get the following core dump:
It seems to me that some Widget/Layout we are using is not supported
anymore!?
assert(false) within WContainerWidget::createLayoutItemImpl()!
Any idea?
Regards,
Stefan
#0 0x00007ffff6045425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff6048b8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff603e0ee in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff603e192 in __assert_fail () from
/lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff733faa7 in Wt::WContainerWidget::createLayoutItemImpl
(this=<optimized out>, item=0x7fffd4031570) at
/home/ruppert/work/wt/wt-3.3.0-rc2/src/Wt/WContainerWidget.C:176
#5 0x00007ffff74d9dc5 in Wt::WWidget::createSDomElement (this=0x3762,
app=0x376a) at /home/ruppert/work/wt/wt-3.3.0-rc2/src/Wt/WWidget.C:325
#6 0x00007ffff72b1f16 in Wt::StdWidgetItemImpl::createDomElement
(this=<optimized out>, fitWidth=<optimized out>, fitHeight=<optimized
out>, app=0x7fffd4031570) at
/home/ruppert/work/wt/wt-3.3.0-rc2/src/Wt/StdWidgetItemImpl.C:112
#7 0x00007ffff72ac267 in Wt::StdGridLayoutImpl2::createElement
/* ----------------------------- Image classes ----------------------------- */
class Image : public Wt::WImage
{
public:
virtual void setDisabled(bool disabled);
protected:
Image(const Wt::WString& tooltip,
const Wt::WLink& enabled,
const Wt::WLink& disabled,
const Wt::WLength& width,
const Wt::WLength& height);
Image(const Wt::WString& tooltip,
const Wt::WLink& enabled,
const Wt::WLink& disabled);
virtual void propagateSetEnabled(bool enabled);
private:
void updateToolTip();
private:
Wt::WString mTooltip;
Wt::WLink mEnabled;
Wt::WLink mDisabled;
};
Image::Image(const Wt::WString& tooltip,
const Wt::WLink& enabled,
const Wt::WLink& disabled,
const Wt::WLength& width,
const Wt::WLength& height)
: Wt::WImage()
, mTooltip(tooltip)
, mEnabled(enabled)
, mDisabled(disabled)
{
setImageLink(mEnabled);
setMinimumSize(width, height);
setMaximumSize(width, height);
setVerticalAlignment(Wt::AlignMiddle);
updateToolTip();
}
Image::Image(const Wt::WString& tooltip,
const Wt::WLink& enabled,
const Wt::WLink& disabled)
: Wt::WImage()
, mTooltip(tooltip)
, mEnabled(enabled)
, mDisabled(disabled)
{
setVerticalAlignment(Wt::AlignMiddle);
setImageLink(mEnabled);
updateToolTip();
}
void Image::updateToolTip()
{
if(!mTooltip.empty())
{
if(isEnabled())
setToolTip(mTooltip);
else
setToolTip(Wt::WString("{1}
({2})").arg(mTooltip).arg(Wt::WString::tr("disabled-text")));
}
}
void Image::setDisabled(bool disabled)
{
setImageLink(disabled ? mDisabled : mEnabled);
Wt::WImage::setDisabled(disabled);
updateToolTip();
}
void Image::propagateSetEnabled(bool enabled)
{
setImageLink(enabled ? mEnabled : mDisabled);
Wt::WImage::propagateSetEnabled(enabled);
updateToolTip();
}
// This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
* Copied from WIconPair, Stefan Ruppert.
*
* See the LICENSE file for terms of use.
*/
#ifndef WIMAGEPAIR_H_
#define WIMAGEPAIR_H_
#include <Wt/WCompositeWidget>
#include <Wt/WEvent>
namespace Wt {
class WImage;
/*! \class WIconPair Wt/WIconPair Wt/WIconPair
* \brief A widget that shows one of two icons depending on its state.
*
* This is a utility class that simply manages two images, only one of
* which is shown at a single time, which reflects the current
* 'state'.
*
* The widget may react to click events, by changing state.
*
* <h3>CSS</h3>
*
* This widget does not provide styling,
* and can be styled using inline or external CSS as appropriate.
* The image may be styled via the <tt><img></tt> elements.
*/
class WImagePair : public WCompositeWidget
{
public:
/*! \brief Construct an icon pair from the two icons.
*
* The constructor takes the URL of the two icons. When
* \p clickIsSwitch is set \c true, clicking on the icon will
* switch state.
*/
WImagePair(WImage* image1, WImage* image2,
bool clickIsSwitch = true, WContainerWidget *parent = 0);
/*! \brief Sets the state, which determines the visible icon.
*
* The first icon has number 0, and the second icon has number 1.
*
* The default state is 0.
*
* \sa state()
*/
void setState(int num);
/*! \brief Returns the current state.
*
* \sa setState()
*/
int state() const;
/*! \brief Returns the first icon image
*/
WImage *icon1() const { return icon1_; }
/*! \brief Returns the second icon image
*/
WImage *icon2() const { return icon2_; }
/*! \brief Sets the state to 0 (show icon 1).
*
* \sa setState(int)
*/
void showIcon1();
/*! \brief Sets the state to 1 (show icon 2).
*
* \sa setState(int)
*/
void showIcon2();
/*! \brief %Signal emitted when clicked while in state 0 (icon 1 is
* shown).
*
* Equivalent to:
* \code
* icon1()->clicked()
* \endcode
*/
EventSignal<WMouseEvent>& icon1Clicked();
/*! \brief %Signal emitted when clicked while in state 1 (icon 2 is
* shown).
*
* Equivalent to:
* \code
* icon2()->clicked()
* \endcode
*/
EventSignal<WMouseEvent>& icon2Clicked();
private:
WContainerWidget *impl_;
WImage *icon1_;
WImage *icon2_;
};
}
#endif
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include "Wt/WImage"
#include "Wt/WContainerWidget"
#include "Wt/WCssDecorationStyle"
#include "WImagePair"
namespace Wt {
WImagePair::WImagePair(WImage* image1, WImage* image2,
bool clickIsSwitch, WContainerWidget *parent)
: WCompositeWidget(parent),
impl_(new WContainerWidget()),
icon1_(image1),
icon2_(image2)
{
setImplementation(impl_);
impl_->addWidget(icon1_);
impl_->addWidget(icon2_);
impl_->setLoadLaterWhenInvisible(false);
setInline(true);
icon2_->hide();
if (clickIsSwitch) {
#ifndef WT_TARGET_JAVA
std::string fic1 = icon1_->id();
std::string fic2 = icon2_->id();
std::string hide_1 = WT_CLASS ".hide('" + fic1 +"');";
std::string show_1 = WT_CLASS ".inline('" + fic1 +"');";
std::string hide_2 = WT_CLASS ".hide('" + fic2 +"');";
std::string show_2 = WT_CLASS ".inline('" + fic2 +"');";
implementJavaScript(&WImagePair::showIcon1, hide_2 + show_1
+ WT_CLASS ".cancelEvent(e);");
implementJavaScript(&WImagePair::showIcon2, hide_1 + show_2
+ WT_CLASS ".cancelEvent(e);");
#else
icon1_->clicked().preventPropagation();
icon2_->clicked().preventPropagation();
#endif // WT_TARGET_JAVA
icon1_->clicked().connect(this, &WImagePair::showIcon2);
icon2_->clicked().connect(this, &WImagePair::showIcon1);
decorationStyle().setCursor(PointingHandCursor);
}
}
void WImagePair::setState(int num)
{
if (num == 0) {
icon1_->show();
icon2_->hide();
} else {
icon1_->hide();
icon2_->show();
}
}
int WImagePair::state() const
{
return (icon1_->isHidden() ? 1 : 0);
}
void WImagePair::showIcon1()
{
setState(0);
}
void WImagePair::showIcon2()
{
setState(1);
}
EventSignal<WMouseEvent>& WImagePair::icon1Clicked()
{
return icon1_->clicked();
}
EventSignal<WMouseEvent>& WImagePair::icon2Clicked()
{
return icon2_->clicked();
}
}
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest