Skip to content

Commit 0da96b8

Browse files
author
Koen Deforche
committed
alert for ubuntu compiler bug
1 parent 6476d57 commit 0da96b8

File tree

17 files changed

+209
-40
lines changed

17 files changed

+209
-40
lines changed

CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,32 @@ SET(WTDBO_SOVERSION 26)
2424
SET(WTDBOSQLITE3_SOVERSION 26)
2525
SET(WTDBOPOSTGRES_SOVERSION 26)
2626

27+
#
28+
# Ubuntu patched this compiler to hell
29+
# gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
30+
#
31+
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
32+
ARGS --version
33+
OUTPUT_VARIABLE GCC_COMPILER_VERSION
34+
)
35+
36+
IF(GCC_COMPILER_VERSION MATCHES ".*4\\.4\\.4\\-14ubuntu5.*")
37+
MESSAGE(" ")
38+
MESSAGE(" !!!!! WARNING Your compiler is BUGGY. !!!!! ")
39+
MESSAGE(" ")
40+
MESSAGE(" If possible, upgrade your compiler to e.g. g++ 4.5:")
41+
MESSAGE(" ")
42+
MESSAGE(" $ sudo apt-get install g++-4.5")
43+
MESSAGE(" ")
44+
MESSAGE(" And build using that compiler cmake -DCMAKE_CXX_COMPILER=g++-4.5")
45+
MESSAGE(" ")
46+
MESSAGE(" We will now disable all assertions as a work around, by")
47+
MESSAGE(" building using -DNDEBUG. You will need to define this")
48+
MESSAGE(" also for programs built using Wt")
49+
MESSAGE(" ")
50+
ADD_DEFINITIONS(-DNDEBUG)
51+
ENDIF(GCC_COMPILER_VERSION MATCHES ".*4\\.4\\.4\\-14ubuntu5.*")
52+
2753
#
2854
# Various things that must be configured by the user or packager ...
2955
#

examples/hello/hello.C

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ private:
2727
WText *greeting_;
2828

2929
void greet();
30-
void touch(const WTouchEvent& e);
3130
};
3231

3332
/*
@@ -52,9 +51,6 @@ HelloApplication::HelloApplication(const WEnvironment& env)
5251

5352
greeting_ = new WText(root()); // empty text
5453

55-
root()->touchMove().preventDefaultAction();
56-
root()->touchMove().connect(boost::bind(&HelloApplication::touch, this, _1));
57-
5854
/*
5955
* Connect signals with slots
6056
*
@@ -77,11 +73,6 @@ void HelloApplication::greet()
7773
greeting_->setText("Hello there, " + nameEdit_->text());
7874
}
7975

80-
void HelloApplication::touch(const WTouchEvent& e)
81-
{
82-
std::cerr << "touched" << std::endl;
83-
}
84-
8576
WApplication *createApplication(const WEnvironment& env)
8677
{
8778
/*

examples/widgetgallery/PaintBrush.C

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ PaintBrush::PaintBrush(int width, int height, WContainerWidget *parent)
1818

1919
decorationStyle().setCursor("icons/pencil.cur", CrossCursor);
2020

21-
mouseDragged().connect(this, &PaintBrush::drag);
21+
mouseDragged().connect(this, &PaintBrush::mouseDrag);
2222
mouseWentDown().connect(this, &PaintBrush::mouseDown);
23+
touchStarted().connect(this, &PaintBrush::touchStart);
24+
touchMoved().connect(this, &PaintBrush::touchMove);
25+
touchMoved().preventDefaultAction();
2326

2427
color_ = WColor(black);
2528

@@ -42,13 +45,27 @@ void PaintBrush::paintEvent(WPaintDevice *paintDevice)
4245

4346
void PaintBrush::mouseDown(const WMouseEvent& e)
4447
{
45-
WMouseEvent::Coordinates c = e.widget();
48+
Coordinates c = e.widget();
4649
path_ = WPainterPath(WPointF(c.x, c.y));
4750
}
4851

49-
void PaintBrush::drag(const WMouseEvent& e)
52+
void PaintBrush::touchStart(const WTouchEvent& e)
5053
{
51-
WMouseEvent::Coordinates c = e.widget();
54+
Coordinates c = e.touches()[0].widget();
55+
path_ = WPainterPath(WPointF(c.x, c.y));
56+
}
57+
58+
void PaintBrush::mouseDrag(const WMouseEvent& e)
59+
{
60+
Coordinates c = e.widget();
61+
path_.lineTo(c.x, c.y);
62+
63+
update(PaintUpdate);
64+
}
65+
66+
void PaintBrush::touchMove(const WTouchEvent& e)
67+
{
68+
Coordinates c = e.touches()[0].widget();
5269
path_.lineTo(c.x, c.y);
5370

5471
update(PaintUpdate);

examples/widgetgallery/PaintBrush.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ class PaintBrush : public WPaintedWidget
3232
WColor color_;
3333

3434
void mouseDown(const WMouseEvent& e);
35-
void drag(const WMouseEvent& e);
35+
void mouseDrag(const WMouseEvent& e);
36+
void touchStart(const WTouchEvent& e);
37+
void touchMove(const WTouchEvent& e);
3638
};
3739

3840
#endif // PAINTBRUSH_H_

examples/widgetgallery/WidgetGallery.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ WidgetGallery::WidgetGallery(const WEnvironment& env)
2626
{
2727
setTitle("Wt widgets demo");
2828
setCssTheme("polished");
29+
30+
addMetaHeader("viewport", "width=700, height=1200");
31+
2932
// load text bundles (for the tr() function)
3033
messageResourceBundle().use(appRoot() + "text");
3134
messageResourceBundle().use(appRoot() + "charts");

src/Wt/WAnchor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class WText;
1616
class WImage;
1717

1818
/*! \class WAnchor Wt/WAnchor Wt/WAnchor
19-
* \brief A widget that represents an HTML anchor (to link to other documents)
19+
* \brief A widget that represents an HTML anchor (to link to other documents).
2020
*
2121
* Use an anchor to link to another web page, document, internal
2222
* application path or a resource. The anchor may contain a label
@@ -74,7 +74,7 @@ public:
7474
*/
7575
WAnchor(const std::string& url, WContainerWidget *parent = 0);
7676

77-
/*! \brief Creates an anchor referrring a resource.
77+
/*! \brief Creates an anchor referring a resource.
7878
*
7979
* The \p resource specifies application-dependent content that may
8080
* be generated by your application on demand.

src/Wt/WEvent

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ namespace Wt {
3232
*/
3333
class Touch {
3434
public:
35+
Touch(int identifier,
36+
int clientX, int clientY,
37+
int documentX, int documentY,
38+
int screenX, int screenY,
39+
int widgetX, int widgetY);
40+
3541
Coordinates document() const { return Coordinates(documentX_, documentY_); }
3642
Coordinates window() const { return Coordinates(clientX_, clientY_); }
3743
Coordinates screen() const { return Coordinates(screenX_, screenY_); }

src/Wt/WEvent.C

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616
namespace {
1717
using namespace Wt;
1818

19+
int asInt(const std::string& v) {
20+
return boost::lexical_cast<int>(v);
21+
}
22+
1923
int parseIntParameter(const WebRequest& request, const std::string& name,
2024
int ifMissing) {
2125
const std::string *p;
2226

2327
if ((p = request.getParameter(name))) {
2428
try {
25-
return boost::lexical_cast<int>(*p);
29+
return asInt(*p);
2630
} catch (const boost::bad_lexical_cast& ee) {
2731
wApp->log("error") << "Could not cast event property '" << name
2832
<< ": " << *p << "' to int";
@@ -41,10 +45,50 @@ namespace {
4145
} else
4246
return std::string();
4347
}
48+
49+
void decodeTouches(std::string str, std::vector<Touch>& result) {
50+
if (str.empty())
51+
return;
52+
53+
std::vector<std::string> s;
54+
boost::split(s, str, boost::is_any_of(";"));
55+
56+
if (s.size() % 9) {
57+
wApp->log("error") << "Could not parse touches array '" << str << "'";
58+
return;
59+
}
60+
61+
try {
62+
for (unsigned i = 0; i < s.size(); i += 9) {
63+
result.push_back(Touch(asInt(s[i + 0]),
64+
asInt(s[i + 1]), asInt(s[i + 2]),
65+
asInt(s[i + 3]), asInt(s[i + 4]),
66+
asInt(s[i + 5]), asInt(s[i + 6]),
67+
asInt(s[i + 7]), asInt(s[i + 8])));
68+
}
69+
} catch (const boost::bad_lexical_cast& ee) {
70+
wApp->log("error") << "Could not parse touches array '" << str << "'";
71+
return;
72+
}
73+
}
4474
}
4575

4676
namespace Wt {
4777

78+
Touch::Touch(int identifier,
79+
int clientX, int clientY,
80+
int documentX, int documentY,
81+
int screenX, int screenY,
82+
int widgetX, int widgetY)
83+
: identifier_(identifier),
84+
clientX_(clientX),
85+
clientY_(clientY),
86+
documentX_(documentX),
87+
documentY_(documentY),
88+
widgetX_(widgetX),
89+
widgetY_(widgetY)
90+
{ }
91+
4892
JavaScriptEvent::JavaScriptEvent()
4993
{ }
5094

@@ -124,6 +168,10 @@ void JavaScriptEvent::get(const WebRequest& request, const std::string& se)
124168
(getStringParameter(request, se + "a"
125169
+ boost::lexical_cast<std::string>(i)));
126170
}
171+
172+
decodeTouches(getStringParameter(request, se + "touches"), touches);
173+
decodeTouches(getStringParameter(request, se + "ttouches"), targetTouches);
174+
decodeTouches(getStringParameter(request, se + "ctouches"), changedTouches);
127175
}
128176

129177
WMouseEvent::WMouseEvent()
@@ -229,4 +277,15 @@ WTouchEvent::WTouchEvent(const JavaScriptEvent& jsEvent)
229277
WTouchEvent WTouchEvent::templateEvent;
230278
#endif // WT_TARGET_JAVA;
231279

280+
WGestureEvent::WGestureEvent()
281+
{ }
282+
283+
WGestureEvent::WGestureEvent(const JavaScriptEvent& jsEvent)
284+
: jsEvent_(jsEvent)
285+
{ }
286+
287+
#ifdef WT_TARGET_JAVA
288+
WGestureEvent WGestureEvent::templateEvent;
289+
#endif // WT_TARGET_JAVA;
290+
232291
}

src/Wt/WInteractWidget

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ public:
226226
*/
227227
EventSignal<WMouseEvent>& mouseWheel();
228228

229-
EventSignal<WTouchEvent>& touchStart();
230-
EventSignal<WTouchEvent>& touchEnd();
231-
EventSignal<WTouchEvent>& touchMove();
229+
EventSignal<WTouchEvent>& touchStarted();
230+
EventSignal<WTouchEvent>& touchEnded();
231+
EventSignal<WTouchEvent>& touchMoved();
232232

233-
EventSignal<WGestureEvent>& gestureStart();
234-
EventSignal<WGestureEvent>& gestureChange();
235-
EventSignal<WGestureEvent>& gestureEnd();
233+
EventSignal<WGestureEvent>& gestureStarted();
234+
EventSignal<WGestureEvent>& gestureChanged();
235+
EventSignal<WGestureEvent>& gestureEnded();
236236

237237
/*! \brief Configure dragging for drag and drop.
238238
*

src/Wt/WInteractWidget.C

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,36 @@ EventSignal<WMouseEvent>& WInteractWidget::mouseWheel()
122122
return *mouseEventSignal(MOUSE_WHEEL_SIGNAL, true);
123123
}
124124

125-
EventSignal<WTouchEvent>& WInteractWidget::touchMove()
125+
EventSignal<WTouchEvent>& WInteractWidget::touchStarted()
126+
{
127+
return *touchEventSignal(TOUCH_START_SIGNAL, true);
128+
}
129+
130+
EventSignal<WTouchEvent>& WInteractWidget::touchMoved()
126131
{
127132
return *touchEventSignal(TOUCH_MOVE_SIGNAL, true);
128133
}
129134

135+
EventSignal<WTouchEvent>& WInteractWidget::touchEnded()
136+
{
137+
return *touchEventSignal(TOUCH_END_SIGNAL, true);
138+
}
139+
140+
EventSignal<WGestureEvent>& WInteractWidget::gestureStarted()
141+
{
142+
return *gestureEventSignal(GESTURE_START_SIGNAL, true);
143+
}
144+
145+
EventSignal<WGestureEvent>& WInteractWidget::gestureChanged()
146+
{
147+
return *gestureEventSignal(GESTURE_CHANGE_SIGNAL, true);
148+
}
149+
150+
EventSignal<WGestureEvent>& WInteractWidget::gestureEnded()
151+
{
152+
return *gestureEventSignal(GESTURE_END_SIGNAL, true);
153+
}
154+
130155
void WInteractWidget::updateDom(DomElement& element, bool all)
131156
{
132157
bool updateKeyDown = false;

0 commit comments

Comments
 (0)