]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Misc fixes TimePath/test
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 3 Jun 2018 01:50:39 +0000 (11:50 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 3 Jun 2018 01:56:28 +0000 (11:56 +1000)
16 files changed:
CMakeLists.txt
libs/globaldefs.h
libs/gtkutil/cursor.cpp
libs/gtkutil/dialog.cpp
libs/gtkutil/glwidget.cpp
libs/string/string.h
libs/uilib/uilib.cpp
libs/uilib/uilib.h
libs/versionlib.h
radiant/brush.h
radiant/surfacedialog.cpp
radiant/texwindow.cpp
radiant/texwindow.h
radiant/treemodel.cpp
radiant/winding.cpp
tools/quake3/q3map2/light_ydnar.c

index 95fa439ffb73caffebf04c360fea956ffd201766..40975004ea72f140e6536350eac4cca14e3c5b25 100644 (file)
@@ -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}"
index 146dd788b1c5d24209b3f89836f92bc21ae11636..e2dea933e336b57ccbd439cf5bda87632c5205d7 100644 (file)
 #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
index 671775716451cbecf13cbcc260784cf96b736a07..58edaa257c9e89f3d97664c79d4f99e3b0540756 100644 (file)
 
 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)
index 9024e2871012c293135588fd65972b0b094377ab..cc863053c4437c9ad5afe8dce088aaa96d9bd542 100644 (file)
@@ -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;
 }
index 52cec49cf2a58d329001a7ad12a2e1ad7dfc4926..53478d0df0fe354e62fb9311994c016d2de75412 100644 (file)
@@ -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);
 
index ff7dc4536c9245ce116e612534f0d1ff826a49a6..21b1dd0cc0baec427ea464330414eb24e3c1564b 100644 (file)
@@ -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.
index 93e6e604c7d8844eb431ab11c8208a812514f7c2..b7724b6051242e348f4fd2d7bad782a3916c11a2 100644 (file)
@@ -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<self>::test(*static_cast<self>(const_cast<pointer_remove_const<decltype(this)>::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);
 
index 96e0d54a6b3f842fc8a95ce608a17c288e2b1c91..7afd8b68ecb1c76f3341804f7cb5602cb0efdb6c 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef INCLUDED_UILIB_H
 #define INCLUDED_UILIB_H
 
+#include "globaldefs.h"
+
 #include <string>
 #include <glib-object.h>
 
@@ -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<self>(this))
-#pragma clang diagnostic pop
+WARNING_RESTORE_CLANG(keyword-macro)
 
     template<class Lambda>
     gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, void *data)
index 75704cf15d13ab97b8b50baef4766d045c67316e..a870cb3aa4e29b335a47289dd97d084b9e213ea9 100644 (file)
@@ -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';
        }
index 9955bfbadf1caaa920da178adc553b1e1a40bf2d..f94ecd7bad23b194a85e22a5ec78183e080befd1 100644 (file)
@@ -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
index b9926714e472eda7844fb7bb15696548f0a30ad3..3fbae32e1f19981040ce3419093e64326a491df6 100644 (file)
@@ -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);
index e6afb71df3fd16eeae61d3b577ae76d33b6060c7..cf5202b379804a6671c8c3d3bdf1307c61e304d9 100644 (file)
@@ -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()
index 5c5e5d8fa16721395d3f7ed8803608d56439103e..9761c8ef76054b8a1b013959a9b8d541554d4d9f 100644 (file)
@@ -31,6 +31,7 @@
 
 class TextureBrowser;
 
+#define g_TextureBrowser GlobalTextureBrowser()
 TextureBrowser &GlobalTextureBrowser();
 
 ui::Widget TextureBrowser_constructWindow(ui::Window toplevel);
index c0463bee52fa2958e00aea30a23a1527b2ebd4ad..074562bfc76b56003c4e888a052f07a9098fa4fa 100644 (file)
@@ -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);
 
index d027f52dba2ab4a41ec968a655c4b27e39221a36..b956dc7e767fe536f6e2fab42379ae3053b1f7db 100644 (file)
@@ -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;
index f75810bdf00915c3d498d02e2204e6a8431efb2d..a5cf89106187c6d5f0a4875ccad2deca39bc8ec6 100644 (file)
@@ -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;
                                }