Skip to content

Commit

Permalink
Cherry-picking fixes from master branch into 4.3-release branch:
Browse files Browse the repository at this point in the history
 - Fix AbstractQuery's copy ctor/assignment operator not copying join_ field
   Added test for AbstractQuery::join()
   join() was working properly, but AbstractQuery's copy ctor was not: it
   did not copy the join_ field.
 - widgetgallery: Fixed WDataSeries doc-link
 - WWebWidget: move id_ out of OtherImpl
   This fixes an issue when setId() is used.
   The destructor of jsScrollVisibilityChanged_ (a JSignal) in OtherImpl
   uses WWebWidget::id() to unexpose the signal. However, resetting the
   otherImpl_ causes it to be set to nullptr, so the WObject's id is used
   instead of the id set in OtherImpl.
   Simply moving this id_ out of OtherImpl and making sure it gets
   destroyed after OtherImpl solves this problem.
 - Changing Windows libs to lowercase
   When cross-compiling with MinGW on Linux, the libraries are lowercase,
   and Windows is case-insensitive, so let's make them all lowercase.
 - Issue #7505: it's not necessary to disable Direct2D/DirectWrite with MinGW
   It works fine, even when cross-compiling (tested on Fedora), so let's
   just enable it.
  • Loading branch information
RockinRoel committed Apr 20, 2020
1 parent 61563b1 commit 1d18db5
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 24 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ ENDIF(BOOST_WT_MT_FOUND)

# decide on GraphicsMagick vs skia
# todo: set default to whatever was found
IF (WIN32 AND NOT MINGW)
IF (WIN32)
SET(WT_WRASTERIMAGE_DEFAULT_IMPLEMENTATION "Direct2D")
ELSE (WIN32 AND NOT MINGW)
ELSE (WIN32)
SET(WT_WRASTERIMAGE_DEFAULT_IMPLEMENTATION "none")
ENDIF (WIN32 AND NOT MINGW)
ENDIF (WIN32)

SET(WT_WRASTERIMAGE_IMPLEMENTATION ${WT_WRASTERIMAGE_DEFAULT_IMPLEMENTATION} CACHE STRING "Implementation for WRasterImage server-side rendering")
IF (CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 8)
Expand All @@ -348,9 +348,9 @@ ELSEIF (${WT_WRASTERIMAGE_IMPLEMENTATION} STREQUAL "skia")
ENDIF (NOT SKIA_FOUND)
SET(WT_HAS_WRASTERIMAGE true)
ELSEIF (${WT_WRASTERIMAGE_IMPLEMENTATION} STREQUAL "Direct2D")
IF (WIN32 AND NOT MINGW)
IF (WIN32)
SET(WT_HAS_WRASTERIMAGE true)
ENDIF (WIN32 AND NOT MINGW)
ENDIF (WIN32)
ELSE (${WT_WRASTERIMAGE_IMPLEMENTATION} STREQUAL "GraphicsMagick")
MESSAGE("** Disabled WRasterimage support. Set WT_WRASTERIMAGE_IMPLEMENTATION to GraphicsMagick, skia, or Direct2D.")
ENDIF (${WT_WRASTERIMAGE_IMPLEMENTATION} STREQUAL "GraphicsMagick")
Expand Down
2 changes: 1 addition & 1 deletion cmake/WtFindGL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ELSE(USE_SYSTEM_GLEW)
ENDIF(USE_SYSTEM_GLEW)

IF(WIN32)
SET(GL_LIBRARIES Opengl32)
SET(GL_LIBRARIES opengl32)
ELSEIF(APPLE)
FIND_LIBRARY(GL_LIBRARIES OpenGL)
ELSEIF(UNIX)
Expand Down
2 changes: 1 addition & 1 deletion cmake/WtFindMysql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ IF(WIN32)
# on zlib, depends on ws2_32 and Shlwapi on Windows
IF(_MYSQL_DEBUG_LIB_FILENAME STREQUAL "mariadbclientd" OR
_MYSQL_LIB_FILENAME STREQUAL "mariadbclient")
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${ZLIB_LIBRARIES} ws2_32 Shlwapi)
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${ZLIB_LIBRARIES} ws2_32 shlwapi)
ENDIF()
set(_MYSQL_DEBUG_LIB_FILENAME)
set(_MYSQL_LIB_FILENAME)
Expand Down
2 changes: 1 addition & 1 deletion cmake/WtFindOdbc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - ODBC_PREFIX

IF(WIN32)
SET(ODBC_LIBRARY Odbc32)
SET(ODBC_LIBRARY odbc32)
SET(ODBC_LIBRARIES ${ODBC_LIBRARY})
SET(ODBC_INCLUDE "")
SET(ODBC_FOUND TRUE)
Expand Down
2 changes: 1 addition & 1 deletion cmake/WtFindSkia.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ IF(WIN32)
optimized ${SKIA_SKGPU_LIB_R}
debug ${SKIA_SKGPU_LIB_D}
Usp10.lib
Opengl32.lib
opengl32.lib
)

IF(SKIA_OPTS_SSE41_LIB_D AND SKIA_OPTS_SSE41_LIB_R)
Expand Down
2 changes: 1 addition & 1 deletion examples/widgetgallery/approot/text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4218,7 +4218,7 @@
values corresponding to each category are plotted consecutively in model
row order. Each data series corresponds to a column from the model and
may be rendered differently (This is configured in the data series - See
${doc-link WDataSeries} for more information).
${doc-link Chart-WDataSeries} for more information).
</p>
<p>
As a cartesian chart it provides automatic configuration of the axes, and
Expand Down
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ SET(WT_FONTSUPPORT_SIMPLE false)
SET(WT_FONTSUPPORT_PANGO false)
SET(WT_FONTSUPPORT_DIRECTWRITE false)
SET(HAVE_DIRECTWRITE false)
IF(WIN32 AND NOT MINGW)
IF(WIN32)
SET(HAVE_DIRECTWRITE true)
ENDIF(WIN32 AND NOT MINGW)
ENDIF(WIN32)

IF(HAVE_HARU OR "${WT_WRASTERIMAGE_IMPLEMENTATION}" STREQUAL "GraphicsMagick" OR "${WT_WRASTERIMAGE_IMPLEMENTATION}" STREQUAL "Direct2D")
IF(HAVE_PANGO AND NOT "${WT_WRASTERIMAGE_IMPLEMENTATION}" STREQUAL "Direct2D")
Expand Down Expand Up @@ -602,7 +602,7 @@ ELSEIF("${WT_WRASTERIMAGE_IMPLEMENTATION}" STREQUAL "skia")
INCLUDE_DIRECTORIES(${SKIA_INCLUDE_DIRS})
ADD_DEFINITIONS(${SKIA_DEFINES})
ELSEIF("${WT_WRASTERIMAGE_IMPLEMENTATION}" STREQUAL "Direct2D")
TARGET_LINK_LIBRARIES(wt PRIVATE D2d1 Dwrite Windowscodecs Shlwapi)
TARGET_LINK_LIBRARIES(wt PRIVATE d2d1 dwrite windowscodecs shlwapi)
ELSE("${WT_WRASTERIMAGE_IMPLEMENTATION}" STREQUAL "GraphicsMagick")
MESSAGE("** Disabling raster image support (WRasterImage): set WT_WRASTERIMAGE_IMPLEMENTATION to GraphicsMagick or skia.")
ENDIF("${WT_WRASTERIMAGE_IMPLEMENTATION}" STREQUAL "GraphicsMagick")
Expand All @@ -629,7 +629,7 @@ ELSEIF(WT_FONTSUPPORT_PANGO)
ADD_DEFINITIONS(-DWT_FONTSUPPORT_PANGO)
MESSAGE("** Enabling advanced font support using libpango")
ELSEIF(WT_FONTSUPPORT_DIRECTWRITE)
TARGET_LINK_LIBRARIES(wt PRIVATE Dwrite)
TARGET_LINK_LIBRARIES(wt PRIVATE dwrite)
ADD_DEFINITIONS(-DWT_FONTSUPPORT_DIRECTWRITE)
MESSAGE("** Enabling advanced font support using DirectWrite")
ENDIF(WT_FONTSUPPORT_SIMPLE)
Expand Down
4 changes: 3 additions & 1 deletion src/Wt/Dbo/Query.C
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ AbstractQuery::~AbstractQuery()
{ }

AbstractQuery::AbstractQuery(const AbstractQuery& other)
: where_(other.where_),
: join_(other.join_),
where_(other.where_),
groupBy_(other.groupBy_),
having_(other.having_),
orderBy_(other.orderBy_),
Expand All @@ -347,6 +348,7 @@ AbstractQuery::AbstractQuery(const AbstractQuery& other)

AbstractQuery& AbstractQuery::operator=(const AbstractQuery& other)
{
join_ = other.join_;
where_ = other.where_;
groupBy_ = other.groupBy_;
having_ = other.having_;
Expand Down
15 changes: 7 additions & 8 deletions src/Wt/WWebWidget.C
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ WWebWidget::OtherImpl::JavaScriptStatement::JavaScriptStatement

WWebWidget::OtherImpl::OtherImpl(WWebWidget *const self)
: elementTagName_(nullptr),
id_(nullptr),
tabIndex_(std::numeric_limits<int>::min()),
scrollVisibilityMargin_(0),
jsScrollVisibilityChanged_(self, "scrollVisibilityChanged")
Expand Down Expand Up @@ -172,10 +171,10 @@ void WWebWidget::setId(const std::string& id)
app->removeExposedSignal(signal);
}

if (!otherImpl_->id_)
otherImpl_->id_.reset(new std::string());
if (!id_)
id_.reset(new std::string());

*otherImpl_->id_ = id;
*id_ = id;

for (std::size_t i = 0; i < jsignals_.size(); ++i) {
EventSignalBase* signal = jsignals_[i];
Expand All @@ -195,8 +194,8 @@ void WWebWidget::setSelectable(bool selectable)

const std::string WWebWidget::id() const
{
if (otherImpl_ && otherImpl_->id_)
return *otherImpl_->id_;
if (id_)
return *id_;
else
return WWidget::id();
}
Expand Down Expand Up @@ -2195,7 +2194,7 @@ std::string WWebWidget::htmlTagName() const
void WWebWidget::setId(DomElement *element, WApplication *app)
{
if (!app->environment().agentIsSpiderBot()
|| (otherImpl_ && otherImpl_->id_)) {
|| id_) {
if (!flags_.test(BIT_FORM_OBJECT))
element->setId(id());
else
Expand Down Expand Up @@ -2294,7 +2293,7 @@ DomElement *WWebWidget::createStubElement(WApplication *app)
stub->setProperty(Property::InnerHTML, "...");

if (!app->environment().agentIsSpiderBot()
|| (otherImpl_ && otherImpl_->id_))
|| id_)
stub->setId(id());

return stub;
Expand Down
8 changes: 7 additions & 1 deletion src/Wt/WWebWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ class WT_API WWebWidget : public WWidget
std::unique_ptr<WLength> width_;
std::unique_ptr<WLength> height_;

/*
* id_ is separate instead of in OtherImpl,
* because it is accessed when OtherImpl is being destroyed,
* from the destructor of jsScrollVisibilityChanged_
*/
std::unique_ptr<std::string> id_;

/*
* Data only stored transiently, during event handling.
*/
Expand Down Expand Up @@ -495,7 +502,6 @@ class WT_API WWebWidget : public WWidget
};

std::unique_ptr<std::string> elementTagName_;
std::unique_ptr<std::string> id_;
std::unique_ptr<std::map<std::string, WT_USTRING> > attributes_;
std::unique_ptr<std::vector<Member> > jsMembers_;
std::unique_ptr<std::vector<JavaScriptStatement> > jsStatements_;
Expand Down
58 changes: 58 additions & 0 deletions test/dbo/DboTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -3159,3 +3159,61 @@ BOOST_AUTO_TEST_CASE( dbo_test39c )
}
#endif
}

BOOST_AUTO_TEST_CASE( dbo_test40 )
{
// Test join function
DboFixture f;
dbo::Session &session = *f.session_;

{
dbo::Transaction t(session);

dbo::ptr<A> a = session.addNew<A>();
a.modify()->i = 5;
dbo::ptr<B> b = session.addNew<B>();
b.modify()->name = "Test";
dbo::ptr<B> b2 = session.addNew<B>();
b2.modify()->name = "Test2";

a.modify()->b = b;
}

{
dbo::Transaction t(session);

dbo::collection<dbo::ptr<A> > results = session.query<dbo::ptr<A> >("select a from \"table_a\" a")
.join("\"table_b\" b on a.\"b_id\" = b.\"id\"")
.where("b.\"name\" = ?")
.bind("Test");

BOOST_REQUIRE(results.size() == 1);

dbo::ptr<A> first = *results.begin();

BOOST_REQUIRE(first);

BOOST_REQUIRE(first->i == 5);
}

{
// This was a bug: AbstractQuery's copy ctor would not copy over the join_ field,
// causing an error

dbo::Transaction t(session);
dbo::Query<dbo::ptr<A> > q = session.query<dbo::ptr<A> >("select a from \"table_a\" a")
.join("\"table_b\" b on a.\"b_id\" = b.\"id\"");

q.where("b.\"name\" = ?").bind("Test");

dbo::collection<dbo::ptr<A> > results = q.resultList();

BOOST_REQUIRE(results.size() == 1);

dbo::ptr<A> first = *results.begin();

BOOST_REQUIRE(first);

BOOST_REQUIRE(first->i == 5);
}
}

0 comments on commit 1d18db5

Please sign in to comment.