Author: thonsew
Date: Tue Aug 30 06:38:22 2011
New Revision: 50949
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50949&view=rev
Log:
Fixed 2 static initialization problems causing core dumps with unit_tests under
GCC 4.6
Modified:
trunk/src/tests/gui/test_gui2.cpp
trunk/src/tests/test_config_cache.cpp
Modified: trunk/src/tests/gui/test_gui2.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/gui/test_gui2.cpp?rev=50949&r1=50948&r2=50949&view=diff
==============================================================================
--- trunk/src/tests/gui/test_gui2.cpp (original)
+++ trunk/src/tests/gui/test_gui2.cpp Tue Aug 30 06:38:22 2011
@@ -131,13 +131,16 @@
typedef std::pair<unsigned, unsigned> tresolution;
typedef std::vector<std::pair<unsigned, unsigned> > tresolution_list;
- CVideo video(CVideo::FAKE_TEST);
+CVideo & video() {
+ CVideo * v_ = new CVideo(CVideo::FAKE_TEST);
+ return *v_;
+}
template<class T>
void test_resolutions(const tresolution_list& resolutions)
{
foreach(const tresolution& resolution, resolutions) {
- video.make_test_fake(resolution.first,
resolution.second);
+ video().make_test_fake(resolution.first,
resolution.second);
std::auto_ptr<gui2::tdialog> dlg(twrapper<T>::create());
BOOST_REQUIRE_MESSAGE(dlg.get(), "Failed to create a
dialog.");
@@ -146,7 +149,7 @@
std::string exception;
try {
- dlg->show(video, 1);
+ dlg->show(video(), 1);
} catch(gui2::tlayout_exception_width_modified&) {
exception =
"gui2::tlayout_exception_width_modified";
} catch(gui2::tlayout_exception_width_resize_failed&) {
@@ -176,7 +179,7 @@
bool interact = false;
for(int i = 0; i < 2; ++i) {
foreach(const tresolution& resolution, resolutions) {
- video.make_test_fake(resolution.first,
resolution.second);
+ video().make_test_fake(resolution.first,
resolution.second);
std::auto_ptr<gui2::tpopup>
dlg(twrapper<T>::create());
BOOST_REQUIRE_MESSAGE(dlg.get(), "Failed to
create a dialog.");
@@ -185,7 +188,7 @@
std::string exception;
try {
- dlg->show(video, interact);
+ dlg->show(video(), interact);
gui2::twindow* window =
gui2::unit_test_window((*dlg.get()));
BOOST_REQUIRE_NE(window, (void*)NULL);
window->draw();
@@ -219,7 +222,7 @@
, const std::string& id)
{
foreach(const tresolution& resolution, resolutions) {
- video.make_test_fake(resolution.first,
resolution.second);
+ video().make_test_fake(resolution.first,
resolution.second);
std::vector<std::string>& list =
gui2::unit_test_registered_window_list();
@@ -235,7 +238,7 @@
* compilers and try to find the cause.
*/
#if 0
- gui2::tip::show(video
+ gui2::tip::show(video()
, id
, "Test messsage for a tooltip."
, gui2::tpoint(0, 0));
@@ -413,11 +416,11 @@
BOOST_AUTO_TEST_CASE(test_make_test_fake)
{
- video.make_test_fake(10, 10);
+ video().make_test_fake(10, 10);
try {
gui2::tmessage dlg("title", "message", true);
- dlg.show(video, 1);
+ dlg.show(video(), 1);
} catch(twml_exception& e) {
BOOST_CHECK(e.user_message == _("Failed to show a dialog, "
"which doesn't fit on the screen."));
Modified: trunk/src/tests/test_config_cache.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_config_cache.cpp?rev=50949&r1=50948&r2=50949&view=diff
==============================================================================
--- trunk/src/tests/test_config_cache.cpp (original)
+++ trunk/src/tests/test_config_cache.cpp Tue Aug 30 06:38:22 2011
@@ -54,25 +54,24 @@
class test_config_cache : public game_config::config_cache {
test_config_cache() : game_config::config_cache() {}
- static test_config_cache cache_;
-
public:
- static test_config_cache& instance() {
- return cache_;
- }
+ static test_config_cache& instance() ;
void set_force_invalid_cache(bool force)
{
game_config::config_cache::set_force_invalid_cache(force);
}
};
+
+test_config_cache & test_config_cache::instance() {
+ static test_config_cache * cache_ = new test_config_cache;
+ return *cache_;
+}
/**
* Used to redirect defines settings to test cache
**/
typedef game_config::scoped_preproc_define_internal<test_config_cache>
test_scoped_define;
-
-test_config_cache test_config_cache::cache_;
struct config_cache_fixture {
config_cache_fixture() : cache(test_config_cache::instance()),
old_locale(get_language()), test_def("TEST")
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits