Changeset - r21931:d35ef28a5c46
[Not reviewed]
master
0 2 0
alberth - 9 years ago 2014-12-18 18:20:59
alberth@openttd.org
(svn r27085) -Fix: Always return a valid window to the world generation gui code.
2 files changed with 7 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/genworld_gui.cpp
Show inline comments
 
@@ -837,7 +837,8 @@ static void _ShowGenerateLandscape(Genen
 
		if (!GetHeightmapDimensions(_file_to_saveload.name, &x, &y)) return;
 
	}
 

	
 
	GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>((mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
 
	WindowDesc *desc = (mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc;
 
	GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>(desc, mode, true);
 

	
 
	if (mode == GLWM_HEIGHTMAP) {
 
		w->x = x;
src/window_gui.h
Show inline comments
 
@@ -851,12 +851,14 @@ Window *FindWindowFromPt(int x, int y);
 
 * @tparam Wcls %Window class to use if the window does not exist.
 
 * @param desc The pointer to the WindowDesc to be created
 
 * @param window_number the window number of the new window
 
 * @return %Window pointer of the newly created window, or \c NULL.
 
 * @param return_existing If set, also return the window if it already existed.
 
 * @return %Window pointer of the newly created window, or the existing one if \a return_existing is set, or \c NULL.
 
 */
 
template <typename Wcls>
 
Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number)
 
Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_existing = false)
 
{
 
	if (BringWindowToFrontById(desc->cls, window_number)) return NULL;
 
	Wcls *w = static_cast<Wcls *>(BringWindowToFrontById(desc->cls, window_number));
 
	if (w != NULL) return return_existing ? w : NULL;
 
	return new Wcls(desc, window_number);
 
}
 

	
0 comments (0 inline, 0 general)