From: TimePath Date: Sun, 3 Jun 2018 01:50:39 +0000 (+1000) Subject: Misc fixes X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2FTimePath%2Ftest;p=xonotic%2Fnetradiant.git Misc fixes --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 95fa439f..40975004 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,12 @@ endif () if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") addflags("-Werror") addflags("-pedantic-errors") + set(CMAKE_VERBOSE_MAKEFILE ON) + addflags(-fstack-protector -fstack-protector-strong -fstack-protector-all) + #addflags("-fsanitize=address,undefined") # break __asan::ReportGenericError + + #add_definitions(-D_GLIBCXX_DEBUG=1) + #add_definitions(-D_GLIBCXX_DEBUG_PEDANTIC=1) endif () addflags("-Wall") @@ -89,6 +95,7 @@ addflags("-Wextra") addflags("-pedantic") addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown +addflags_cxx("-Wno-deprecated-declarations") # various gtk addflags("-Wno-unused-function") addflags("-Wno-unused-variable") @@ -109,9 +116,6 @@ add_definitions(-DRADIANT_PATCH_VERSION="${NetRadiant_VERSION_PATCH}") add_definitions(-DRADIANT_ABOUTMSG="${NetRadiant_ABOUT}") -add_definitions(-D_GLIBCXX_DEBUG=1) -add_definitions(-D_GLIBCXX_DEBUG_PEDANTIC=1) - if (NOT CMAKE_BUILD_TYPE MATCHES Release) add_definitions(-D_DEBUG=1) endif () @@ -252,7 +256,7 @@ endif () # Game packs #----------------------------------------------------------------------- -option(DOWNLOAD_GAMEPACKS "Download game packs" ON) +option(DOWNLOAD_GAMEPACKS "Download game packs" OFF) add_custom_target(game_packs_free COMMAND ${CMAKE_COMMAND} -E make_directory games COMMAND DOWNLOAD_GAMEPACKS=yes SOURCE_DIR="${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/install-gamepacks.sh" "${PROJECT_BINARY_DIR}" diff --git a/libs/globaldefs.h b/libs/globaldefs.h index 146dd788..e2dea933 100644 --- a/libs/globaldefs.h +++ b/libs/globaldefs.h @@ -122,4 +122,24 @@ #endif #endif +#define CPP_CAT_(a, b) a ## b +#define CPP_CAT(a, b) CPP_CAT_(a, b) + +#define CPP_STR_(x) #x +#define CPP_STR(x) CPP_STR_(x) + +#define WARNING_SUPPRESS(x) \ + _Pragma (CPP_STR(GCC diagnostic push)) \ + _Pragma (CPP_STR(GCC diagnostic ignored CPP_STR(CPP_CAT(-W,x)))) +#define WARNING_RESTORE(x) \ + _Pragma (CPP_STR(GCC diagnostic pop)) + +#if defined(__clang__) +#define WARNING_SUPPRESS_CLANG(x) WARNING_SUPPRESS(x) +#define WARNING_RESTORE_CLANG(x) WARNING_RESTORE(x) +#else +#define WARNING_SUPPRESS_CLANG(x) +#define WARNING_RESTORE_CLANG(x) +#endif + #endif diff --git a/libs/gtkutil/cursor.cpp b/libs/gtkutil/cursor.cpp index 67177571..58edaa25 100644 --- a/libs/gtkutil/cursor.cpp +++ b/libs/gtkutil/cursor.cpp @@ -30,14 +30,14 @@ GdkCursor *create_blank_cursor() { - return gdk_cursor_new(GDK_BLANK_CURSOR); + return gdk_cursor_new_for_display(gdk_display_get_default(), GDK_BLANK_CURSOR); } void blank_cursor(ui::Widget widget) { GdkCursor *cursor = create_blank_cursor(); gdk_window_set_cursor(gtk_widget_get_window(widget), cursor); - gdk_cursor_unref(cursor); + g_object_unref(cursor); } void default_cursor(ui::Widget widget) diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index 9024e287..cc863053 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -56,8 +56,10 @@ create_dialog_table(unsigned int rows, unsigned int columns, unsigned int row_sp { auto table = ui::Table(rows, columns, FALSE); table.show(); + WARNING_SUPPRESS(deprecated-declarations) gtk_table_set_row_spacings(table, row_spacing); gtk_table_set_col_spacings(table, col_spacing); + WARNING_RESTORE(deprecated-declarations) gtk_container_set_border_width(GTK_CONTAINER(table), border); return table; } diff --git a/libs/gtkutil/glwidget.cpp b/libs/gtkutil/glwidget.cpp index 52cec49c..53478d0d 100644 --- a/libs/gtkutil/glwidget.cpp +++ b/libs/gtkutil/glwidget.cpp @@ -78,7 +78,7 @@ GdkGLContext *glwidget_context_created(ui::GLArea self) ui::GLArea glwidget_new(bool zbuffer) { - auto self = ui::GLArea(GTK_GL_AREA(gtk_gl_area_new())); + auto self = ui::GLArea::from(GTK_GL_AREA(gtk_gl_area_new())); gtk_gl_area_set_has_depth_buffer(self, zbuffer); gtk_gl_area_set_auto_render(self, false); diff --git a/libs/string/string.h b/libs/string/string.h index ff7dc453..21b1dd0c 100644 --- a/libs/string/string.h +++ b/libs/string/string.h @@ -146,8 +146,13 @@ inline bool string_equal_prefix( const char* string, const char* prefix ){ /// \brief Returns true if the ending of \p string is equal to \p suffix. /// O(n) inline bool string_equal_suffix( const char* string, const char* suffix){ - const char *s = string + string_length( string ) - string_length( suffix ); - return string_equal_n( s , suffix, string_length( suffix ) ); + auto aLen = string_length(string); + auto bLen = string_length(suffix); + if (bLen > aLen) { + return false; + } + const char *s = string + aLen - bLen; + return string_equal_n(s , suffix, bLen); } /// \brief Copies \p other into \p string and returns \p string. diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 93e6e604..b7724b60 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -51,10 +51,9 @@ namespace ui { >::type >; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wkeyword-macro" +WARNING_SUPPRESS_CLANG(keyword-macro) #define this (verify::test(*static_cast(const_cast::type>(this)))) -#pragma clang diagnostic pop +WARNING_RESTORE_CLANG(keyword-macro) IMPL(Editable, GTK_EDITABLE); @@ -183,11 +182,13 @@ namespace ui { gtk_window_add_accel_group(this, group); } + WARNING_SUPPRESS(deprecated-declarations) IMPL(Alignment, GTK_ALIGNMENT); Alignment::Alignment(float xalign, float yalign, float xscale, float yscale) : Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale))) {} + WARNING_RESTORE(deprecated-declarations) IMPL(Frame, GTK_FRAME); @@ -231,10 +232,12 @@ namespace ui { GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label))) {} + WARNING_SUPPRESS(deprecated-declarations) IMPL(TearoffMenuItem, GTK_TEAROFF_MENU_ITEM); TearoffMenuItem::TearoffMenuItem(ui::New_t) : TearoffMenuItem(GTK_TEAROFF_MENU_ITEM(gtk_tearoff_menu_item_new())) {} + WARNING_RESTORE(deprecated-declarations) IMPL(ComboBoxText, GTK_COMBO_BOX_TEXT); @@ -263,6 +266,7 @@ namespace ui { gtk_box_pack_end(this, child, expand, fill, padding); } + WARNING_SUPPRESS(deprecated-declarations) IMPL(VBox, GTK_VBOX); VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing))) @@ -282,12 +286,14 @@ namespace ui { VPaned::VPaned(ui::New_t) : VPaned(GTK_VPANED(gtk_vpaned_new())) {} + WARNING_RESTORE(deprecated-declarations) IMPL(Menu, GTK_MENU); Menu::Menu(ui::New_t) : Menu(GTK_MENU(gtk_menu_new())) {} + WARNING_SUPPRESS(deprecated-declarations) IMPL(Table, GTK_TABLE); Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table( @@ -302,6 +308,7 @@ namespace ui { padding.x, padding.y ); } + WARNING_RESTORE(deprecated-declarations) IMPL(TextView, GTK_TEXT_VIEW); @@ -361,6 +368,7 @@ namespace ui { GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits))) {} + WARNING_SUPPRESS(deprecated-declarations) IMPL(HScale, GTK_HSCALE); HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment))) @@ -368,6 +376,7 @@ namespace ui { HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step))) {} + WARNING_RESTORE(deprecated-declarations) IMPL(Adjustment, GTK_ADJUSTMENT); diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 96e0d54a..7afd8b68 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -1,6 +1,8 @@ #ifndef INCLUDED_UILIB_H #define INCLUDED_UILIB_H +#include "globaldefs.h" + #include #include @@ -599,10 +601,9 @@ namespace ui { } } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wkeyword-macro" +WARNING_SUPPRESS_CLANG(keyword-macro) #define this (*static_cast(this)) -#pragma clang diagnostic pop +WARNING_RESTORE_CLANG(keyword-macro) template gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, void *data) diff --git a/libs/versionlib.h b/libs/versionlib.h index 75704cf1..a870cb3a 100644 --- a/libs/versionlib.h +++ b/libs/versionlib.h @@ -52,6 +52,9 @@ inline int string_range_parse_unsigned_decimal_integer( const char* first, const int result = 0; for (; first != last; ++first ) { + if (!isdigit(*first)) { + break; + } result *= 10; result += *first - '0'; } diff --git a/radiant/brush.h b/radiant/brush.h index 9955bfba..f94ecd7b 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -118,40 +118,40 @@ inline void Winding_DrawWireframe(const Winding &winding) inline void Winding_Draw(const Winding &winding, const Vector3 &normal, RenderStateFlags state) { - glVertexPointer(3, GL_FLOAT, sizeof(WindingVertex), &winding.points.data()->vertex); + GLsizei stride = sizeof(WindingVertex); + const WindingVertex *first = winding.points.data(); + auto size = winding.numpoints; + glVertexPointer(3, GL_FLOAT, stride, &first->vertex); if ((state & RENDER_BUMP) != 0) { Vector3 normals[c_brush_maxFaces]; typedef Vector3 *Vector3Iter; - for (Vector3Iter i = normals, end = normals + winding.numpoints; i != end; ++i) { + for (Vector3Iter i = normals, end = normals + size; i != end; ++i) { *i = normal; } if (GlobalShaderCache().useShaderLanguage()) { glNormalPointer(GL_FLOAT, sizeof(Vector3), normals); - glVertexAttribPointerARB(c_attr_TexCoord0, 2, GL_FLOAT, 0, sizeof(WindingVertex), - &winding.points.data()->texcoord); - glVertexAttribPointerARB(c_attr_Tangent, 3, GL_FLOAT, 0, sizeof(WindingVertex), - &winding.points.data()->tangent); - glVertexAttribPointerARB(c_attr_Binormal, 3, GL_FLOAT, 0, sizeof(WindingVertex), - &winding.points.data()->bitangent); + glVertexAttribPointerARB(c_attr_TexCoord0, 2, GL_FLOAT, 0, stride, &first->texcoord); + glVertexAttribPointerARB(c_attr_Tangent, 3, GL_FLOAT, 0, stride, &first->tangent); + glVertexAttribPointerARB(c_attr_Binormal, 3, GL_FLOAT, 0, stride, &first->bitangent); } else { glVertexAttribPointerARB(11, 3, GL_FLOAT, 0, sizeof(Vector3), normals); - glVertexAttribPointerARB(8, 2, GL_FLOAT, 0, sizeof(WindingVertex), &winding.points.data()->texcoord); - glVertexAttribPointerARB(9, 3, GL_FLOAT, 0, sizeof(WindingVertex), &winding.points.data()->tangent); - glVertexAttribPointerARB(10, 3, GL_FLOAT, 0, sizeof(WindingVertex), &winding.points.data()->bitangent); + glVertexAttribPointerARB(8, 2, GL_FLOAT, 0, stride, &first->texcoord); + glVertexAttribPointerARB(9, 3, GL_FLOAT, 0, stride, &first->tangent); + glVertexAttribPointerARB(10, 3, GL_FLOAT, 0, stride, &first->bitangent); } } else { if (state & RENDER_LIGHTING) { Vector3 normals[c_brush_maxFaces]; typedef Vector3 *Vector3Iter; - for (Vector3Iter i = normals, last = normals + winding.numpoints; i != last; ++i) { + for (Vector3Iter i = normals, last = normals + size; i != last; ++i) { *i = normal; } glNormalPointer(GL_FLOAT, sizeof(Vector3), normals); } if (state & RENDER_TEXTURE) { - glTexCoordPointer(2, GL_FLOAT, sizeof(WindingVertex), &winding.points.data()->texcoord); + glTexCoordPointer(2, GL_FLOAT, stride, &first->texcoord); } } #if 0 @@ -163,7 +163,7 @@ inline void Winding_Draw(const Winding &winding, const Vector3 &normal, RenderSt glDrawArrays( GL_LINE_LOOP, 0, GLsizei( winding.numpoints ) ); } #else - glDrawArrays(GL_POLYGON, 0, GLsizei(winding.numpoints)); + glDrawArrays(GL_POLYGON, 0, GLsizei(size)); #endif #if 0 diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index b9926714..3fbae32e 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -1404,8 +1404,6 @@ void TextureClipboard_textureSelected(const char *shader) class TextureBrowser; -extern TextureBrowser g_TextureBrowser; - void TextureBrowser_SetSelectedShader(TextureBrowser &textureBrowser, const char *shader); const char *TextureBrowser_GetSelectedShader(TextureBrowser &textureBrowser); diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index e6afb71d..cf5202b3 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1547,12 +1547,10 @@ gboolean TextureBrowser_expose(ui::Widget widget, GdkEventExpose *event, Texture return FALSE; } - -TextureBrowser g_TextureBrowser; - TextureBrowser &GlobalTextureBrowser() { - return g_TextureBrowser; + static TextureBrowser *_g_TextureBrowser = new TextureBrowser(); + return *_g_TextureBrowser; } bool TextureBrowser_hideUnused() diff --git a/radiant/texwindow.h b/radiant/texwindow.h index 5c5e5d8f..9761c8ef 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -31,6 +31,7 @@ class TextureBrowser; +#define g_TextureBrowser GlobalTextureBrowser() TextureBrowser &GlobalTextureBrowser(); ui::Widget TextureBrowser_constructWindow(ui::Window toplevel); diff --git a/radiant/treemodel.cpp b/radiant/treemodel.cpp index c0463bee..074562bf 100644 --- a/radiant/treemodel.cpp +++ b/radiant/treemodel.cpp @@ -1286,8 +1286,11 @@ void graph_tree_model_erase(GraphTreeModel *model, const scene::Instance &instan GraphTreeNode *parent = graph_tree_model_find_parent(model, instance.path()); - GraphTreeNode::iterator i = parent->find(GraphTreeNode::key_type(node_get_name_safe(instance.path().top().get()), + auto i = parent->find(GraphTreeNode::key_type(node_get_name_safe(instance.path().top().get()), instance.path().top().get_pointer())); + if (i == parent->end()) { + return; + } graph_tree_model_row_deleted(model, i); diff --git a/radiant/winding.cpp b/radiant/winding.cpp index d027f52d..b956dc7e 100644 --- a/radiant/winding.cpp +++ b/radiant/winding.cpp @@ -208,6 +208,9 @@ const double DEBUG_EPSILON_SQUARED = DEBUG_EPSILON * DEBUG_EPSILON; void Winding_Clip(const FixedWinding &winding, const Plane3 &plane, const Plane3 &clipPlane, std::size_t adjacent, FixedWinding &clipped) { + if (!winding.size()) { + return; + } PlaneClassification classification = Winding_ClassifyDistance( plane3_distance_to_point(clipPlane, winding.back().vertex), ON_EPSILON); PlaneClassification nextClassification; diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index f75810bd..a5cf8910 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -3533,7 +3533,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag ){ light_t *light, *light2, **owner; bspLeaf_t *leaf; vec3_t origin, dir, mins, maxs; - float radius, intensity; + float radius = 0.0f, intensity; light_t *buckets[ 256 ]; @@ -3657,7 +3657,6 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag ){ } else { - radius = 0.0f; intensity = light->photons; }