@@ -71,6 +71,30 @@ extern "C"
71
71
#undef __STDC__
72
72
#endif
73
73
74
+ // Vect_rewrite_line and Vect_delete_line use int in GRASS 6 and off_t in GRASS 7 for line id argument.
75
+ // off_t size is not specified by C, POSIX specifies it as signed integer and its size depends on compiler.
76
+ // In OSGeo4W 32bit the off_t size is 8 bytes in GRASS (compiled with MinGW), and 4 bytes QGIS (compiled with MSVC), which is causing crashes.
77
+ // The problem with off_t size was also reported for custom build of QGIS on Xubuntu 14.04 LTS using GRASS 7.0.1-2~ubuntu14.04.1.
78
+ // See: https://lists.osgeo.org/pipermail/grass-dev/2015-June/075539.html
79
+ // https://lists.osgeo.org/pipermail/grass-dev/2015-September/076338.html
80
+ // TODO: get real off_t size from GRASS, probably contribute a patch which will save 'g.version -g' to a header file during compilation
81
+ #if GRASS_VERSION_MAJOR < 7
82
+ typedef int Vect_rewrite_line_function_type ( struct Map_info *, int , int , struct line_pnts *, struct line_cats * );
83
+ typedef int Vect_delete_line_function_type ( struct Map_info *, int );
84
+ #else
85
+ #ifdef Q_OS_WIN
86
+ // TODO: switch to qint64 and compile with msvc (expected comilation error or warning)
87
+ typedef off_t grass_off_t ;
88
+ // typedef qint64 grass_off_t;
89
+ #else
90
+ typedef off_t grass_off_t ;
91
+ #endif
92
+ typedef off_t Vect_rewrite_line_function_type ( struct Map_info *, grass_off_t , int , const struct line_pnts *, const struct line_cats * );
93
+ typedef int Vect_delete_line_function_type ( struct Map_info *, grass_off_t );
94
+ #endif
95
+ Vect_rewrite_line_function_type *Vect_rewrite_line_function_pointer = Vect_rewrite_line;
96
+ Vect_delete_line_function_type *Vect_delete_line_function_pointer = Vect_delete_line;
97
+
74
98
static QString GRASS_KEY = " grass" ;
75
99
76
100
QgsGrassProvider::QgsGrassProvider ( QString uri )
@@ -748,7 +772,7 @@ int QgsGrassProvider::rewriteLine( int oldLid, int type, struct line_pnts *Point
748
772
int newLid = -1 ;
749
773
G_TRY
750
774
{
751
- newLid = Vect_rewrite_line ( map (), oldLid, type, Points, Cats );
775
+ newLid = Vect_rewrite_line_function_pointer ( map (), oldLid, type, Points, Cats );
752
776
753
777
// oldLids are maping to the very first, original version (used by undo)
754
778
int oldestLid = oldLid;
@@ -778,7 +802,7 @@ int QgsGrassProvider::deleteLine( int line )
778
802
if ( !isEdited () )
779
803
return -1 ;
780
804
781
- return ( Vect_delete_line ( map (), line ) );
805
+ return ( Vect_delete_line_function_pointer ( map (), line ) );
782
806
}
783
807
784
808
int QgsGrassProvider::findLine ( double x, double y, int type, double threshold )
0 commit comments