Skip to content

Commit 0a1d44f

Browse files
committed
make qgis_app a shared library and fix some more stl warnings with msvc
1 parent 1632730 commit 0a1d44f

File tree

128 files changed

+248
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+248
-237
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ ADD_DEFINITIONS("-DCORE_EXPORT=${DLLIMPORT}")
494494
ADD_DEFINITIONS("-DGUI_EXPORT=${DLLIMPORT}")
495495
ADD_DEFINITIONS("-DPYTHON_EXPORT=${DLLIMPORT}")
496496
ADD_DEFINITIONS("-DANALYSIS_EXPORT=${DLLIMPORT}")
497+
ADD_DEFINITIONS("-DAPP_EXPORT=${DLLIMPORT}")
497498

498499
#############################################################
499500
# user-changeable settings which can be used to customize

python/core/composer/qgsatlascomposition.sip

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ public:
5050
QString featureFilter() const;
5151
void setFeatureFilter( const QString& expression );
5252

53-
size_t sortKeyAttributeIndex() const;
54-
void setSortKeyAttributeIndex( size_t idx );
53+
int sortKeyAttributeIndex() const;
54+
void setSortKeyAttributeIndex( int idx );
5555

5656
/** Begins the rendering. */
5757
void beginRender();
5858
/** Ends the rendering. Restores original extent */
5959
void endRender();
6060

6161
/** Returns the number of features in the coverage layer */
62-
size_t numFeatures() const;
62+
int numFeatures() const;
6363

6464
/** Prepare the atlas map for the given feature. Sets the extent and context variables */
65-
void prepareForFeature( size_t i );
65+
void prepareForFeature( int i );
6666

6767
/** Returns the current filename. Must be called after prepareForFeature( i ) */
6868
const QString& currentFilename() const;

python/core/qgsgeometry.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class QgsGeometry
6161
/**
6262
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
6363
This class will take ownership of the buffer.
64-
*/
64+
*/
6565
void fromWkb( unsigned char * wkb /Array/, size_t length /ArraySize/ );
6666
%MethodCode
6767
// create copy of Python's string and pass it to fromWkb()

python/core/qgsprojectproperty.sip

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class QgsProperty
1313
@param tabs is number of tabs to print; used for pretty-printing
1414
hierarchy
1515
*/
16-
virtual void dump( size_t tabs = 0 ) const = 0;
16+
virtual void dump( int tabs = 0 ) const = 0;
1717

1818
/** returns true if is a QgsPropertyKey */
1919
virtual bool isKey() const = 0;
@@ -90,15 +90,15 @@ class QgsPropertyValue : QgsProperty
9090
*/
9191
bool isLeaf() const;
9292

93-
void dump( size_t tabs = 0 ) const;
93+
void dump( int tabs = 0 ) const;
9494

9595
bool readXML( QDomNode & keyNode );
9696

9797
bool writeXML( const QString & nodeName,
9898
QDomElement & element,
9999
QDomDocument & document );
100100

101-
size_t count() const;
101+
int count() const;
102102

103103
/** return keys that do not contain other keys
104104

@@ -148,14 +148,14 @@ class QgsPropertyKey : QgsProperty
148148
QgsPropertyValue * setValue( const QVariant & value );
149149

150150

151-
void dump( size_t tabs = 0 ) const;
151+
void dump( int tabs = 0 ) const;
152152

153153
bool readXML( QDomNode & keyNode );
154154

155155
bool writeXML( const QString &nodeName, QDomElement & element, QDomDocument & document );
156156

157157
/// how many elements are contained within this one?
158-
size_t count() const;
158+
int count() const;
159159

160160
/// Does this property not have any subkeys or values?
161161
/* virtual */ bool isEmpty() const;

python/core/raster/qgsrasterbandstats.sip

+3-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ class QgsRasterBandStats
3030
/** \brief The gdal band number (starts at 1)*/
3131
int bandNumber;
3232

33-
/** Color table */
34-
// QList<QgsColorRampShader::ColorRampItem> colorTable;
35-
36-
/** \brief The number of cells in the band. Equivalent to height x width.
37-
* TODO: check if NO_DATA are excluded!*/
38-
int elementCount;
33+
/** \brief The number of not no data cells in the band. */
34+
// TODO: check if no data are excluded in stats calculation
35+
size_t elementCount;
3936

4037
/** \brief The maximum cell value in the raster band. NO_DATA values
4138
* are ignored. This does not use the gdal GetMaximmum function. */

src/analysis/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ INCLUDE_DIRECTORIES(
142142

143143
IF (WIN32)
144144
IF (MSVC)
145-
ADD_DEFINITIONS("-DANALYSIS_EXPORT=__declspec(dllexport)")
145+
ADD_DEFINITIONS("-DANALYSIS_EXPORT=${DLLEXPORT}")
146146
ELSE (MSVC)
147-
ADD_DEFINITIONS("-UANALYSIS_EXPORT \"-DANALYSIS_EXPORT=__declspec(dllexport)\"")
147+
ADD_DEFINITIONS("-UANALYSIS_EXPORT \"-DANALYSIS_EXPORT=${DLLEXPORT}\"")
148148
ENDIF (MSVC)
149149
ENDIF (WIN32)
150150

src/analysis/vector/qgsgeometryanalyzer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ void QgsGeometryAnalyzer::dissolveFeature( QgsFeature& f, int nProcessedFeatures
737737

738738
if ( nProcessedFeatures == 0 )
739739
{
740-
int geomSize = featureGeometry->wkbSize();
740+
size_t geomSize = featureGeometry->wkbSize();
741741
*dissolveGeometry = new QgsGeometry();
742742
unsigned char* wkb = new unsigned char[geomSize];
743743
memcpy( wkb, featureGeometry->asWkb(), geomSize );

src/app/CMakeLists.txt

+11-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,16 @@ ELSE (ANDROID)
456456
ADD_EXECUTABLE(${QGIS_APP_NAME} MACOSX_BUNDLE WIN32 main.cpp ${QGIS_APP_SRCS} ${QGIS_APP_MOC_SRCS} ${IMAGE_RCC_SRCS} ${TEST_RCC_SRCS})
457457
ENDIF (ANDROID)
458458

459+
IF (WIN32)
460+
IF (MSVC)
461+
ADD_DEFINITIONS("-DAPP_EXPORT=${DLLEXPORT}")
462+
ELSE (MSVC)
463+
ADD_DEFINITIONS("-UAPP_EXPORT \"-DAPP_EXPORT=${DLLEXPORT}\"")
464+
ENDIF (MSVC)
465+
ENDIF (WIN32)
466+
459467
# shared library used by tests - TODO: use it also for qgis executable?
460-
ADD_LIBRARY(qgis_app STATIC ${QGIS_APP_SRCS} ${QGIS_APP_MOC_SRCS} ${QGIS_APP_HDRS} ${QGIS_APP_MOC_HDRS} ${IMAGE_RCC_SRCS})
468+
ADD_LIBRARY(qgis_app SHARED ${QGIS_APP_SRCS} ${QGIS_APP_MOC_SRCS} ${QGIS_APP_HDRS} ${QGIS_APP_MOC_HDRS} ${IMAGE_RCC_SRCS})
461469

462470
TARGET_LINK_LIBRARIES(qgis_app
463471
${QWT_LIBRARY}
@@ -498,6 +506,7 @@ ENDIF (ANDROID)
498506
IF(WIN32)
499507
ADD_DEFINITIONS(-DQWT_DLL)
500508
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} DbgHelp)
509+
TARGET_LINK_LIBRARIES(qgis_app DbgHelp)
501510
ENDIF(WIN32)
502511

503512
IF (APPLE)
@@ -511,7 +520,7 @@ ENDIF(APPLE)
511520

512521
IF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
513522
FIND_LIBRARY(EXECINFO_LIBRARY NAMES execinfo)
514-
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${EXECINFO_LIBRARY})
523+
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${EXECINFO_LIBRARY})
515524
ENDIF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
516525

517526
IF (POSTGRES_FOUND)

src/app/main.cpp

+1-44
Original file line numberDiff line numberDiff line change
@@ -149,49 +149,6 @@ bool bundleclicked( int argc, char *argv[] )
149149
return ( argc > 1 && memcmp( argv[1], "-psn_", 5 ) == 0 );
150150
}
151151

152-
#ifdef Q_OS_WIN
153-
LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
154-
{
155-
QString dumpName = QDir::toNativeSeparators(
156-
QString( "%1\\qgis-%2-%3-%4-%5.dmp" )
157-
.arg( QDir::tempPath() )
158-
.arg( QDateTime::currentDateTime().toString( "yyyyMMdd-hhmmss" ) )
159-
.arg( GetCurrentProcessId() )
160-
.arg( GetCurrentThreadId() )
161-
.arg( QGis::QGIS_DEV_VERSION )
162-
);
163-
164-
QString msg;
165-
HANDLE hDumpFile = CreateFile( dumpName.toLocal8Bit(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0 );
166-
if ( hDumpFile != INVALID_HANDLE_VALUE )
167-
{
168-
MINIDUMP_EXCEPTION_INFORMATION ExpParam;
169-
ExpParam.ThreadId = GetCurrentThreadId();
170-
ExpParam.ExceptionPointers = ExceptionInfo;
171-
ExpParam.ClientPointers = TRUE;
172-
173-
if ( MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpWithDataSegs, ExceptionInfo ? &ExpParam : NULL, NULL, NULL ) )
174-
{
175-
msg = QObject::tr( "minidump written to %1" ).arg( dumpName );
176-
}
177-
else
178-
{
179-
msg = QObject::tr( "writing of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
180-
}
181-
182-
CloseHandle( hDumpFile );
183-
}
184-
else
185-
{
186-
msg = QObject::tr( "creation of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
187-
}
188-
189-
QMessageBox::critical( 0, QObject::tr( "Crash dumped" ), msg );
190-
191-
return EXCEPTION_EXECUTE_HANDLER;
192-
}
193-
#endif
194-
195152
void myPrint( const char *fmt, ... )
196153
{
197154
va_list ap;
@@ -421,7 +378,7 @@ int main( int argc, char *argv[] )
421378
#endif
422379

423380
#ifdef Q_OS_WIN
424-
SetUnhandledExceptionFilter( qgisCrashDump );
381+
SetUnhandledExceptionFilter( QgisApp::qgisCrashDump );
425382
#endif
426383

427384
// initialize random number seed

src/app/qgisapp.cpp

+45-4
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,11 @@ extern "C"
277277

278278
#include "qgspythonutils.h"
279279

280-
#ifndef WIN32
280+
#ifndef Q_OS_WIN
281281
#include <dlfcn.h>
282282
#else
283283
#include <windows.h>
284+
#include <DbgHelp.h>
284285
#endif
285286

286287
#ifdef HAVE_TOUCH
@@ -8864,14 +8865,11 @@ void QgisApp::keyPressEvent( QKeyEvent * e )
88648865
{
88658866
stopRendering();
88668867
}
8867-
#if 0
88688868
#if defined(Q_OS_WIN)&& defined(QGISDEBUG)
88698869
else if ( e->key() == Qt::Key_Backslash && e->modifiers() & Qt::ControlModifier )
88708870
{
8871-
extern LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo );
88728871
qgisCrashDump( 0 );
88738872
}
8874-
#endif
88758873
#endif
88768874
else
88778875
{
@@ -9403,3 +9401,46 @@ void QgisApp::tapAndHoldTriggered( QTapAndHoldGesture *gesture )
94039401
}
94049402
}
94059403
#endif
9404+
9405+
#ifdef Q_OS_WIN
9406+
LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
9407+
{
9408+
QString dumpName = QDir::toNativeSeparators(
9409+
QString( "%1\\qgis-%2-%3-%4-%5.dmp" )
9410+
.arg( QDir::tempPath() )
9411+
.arg( QDateTime::currentDateTime().toString( "yyyyMMdd-hhmmss" ) )
9412+
.arg( GetCurrentProcessId() )
9413+
.arg( GetCurrentThreadId() )
9414+
.arg( QGis::QGIS_DEV_VERSION )
9415+
);
9416+
9417+
QString msg;
9418+
HANDLE hDumpFile = CreateFile( dumpName.toLocal8Bit(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0 );
9419+
if ( hDumpFile != INVALID_HANDLE_VALUE )
9420+
{
9421+
MINIDUMP_EXCEPTION_INFORMATION ExpParam;
9422+
ExpParam.ThreadId = GetCurrentThreadId();
9423+
ExpParam.ExceptionPointers = ExceptionInfo;
9424+
ExpParam.ClientPointers = TRUE;
9425+
9426+
if ( MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpWithDataSegs, ExceptionInfo ? &ExpParam : NULL, NULL, NULL ) )
9427+
{
9428+
msg = QObject::tr( "minidump written to %1" ).arg( dumpName );
9429+
}
9430+
else
9431+
{
9432+
msg = QObject::tr( "writing of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
9433+
}
9434+
9435+
CloseHandle( hDumpFile );
9436+
}
9437+
else
9438+
{
9439+
msg = QObject::tr( "creation of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
9440+
}
9441+
9442+
QMessageBox::critical( 0, QObject::tr( "Crash dumped" ), msg );
9443+
9444+
return EXCEPTION_EXECUTE_HANDLER;
9445+
}
9446+
#endif

src/app/qgisapp.h

+12-6
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ class QgsTileScaleWidget;
100100
#include <QTapAndHoldGesture>
101101
#endif
102102

103+
#ifdef Q_OS_WIN
104+
#include <windows.h>
105+
#endif
106+
103107
/*! \class QgisApp
104108
* \brief Main window for the Qgis application
105109
*/
106-
class QgisApp : public QMainWindow, private Ui::MainWindow
110+
class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
107111
{
108112
Q_OBJECT
109113
public:
@@ -425,11 +429,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
425429
* @note added in 1.9 */
426430
int messageTimeout();
427431

428-
#ifdef Q_OS_WIN
429-
//! ugly hack
430-
void skipNextContextMenuEvent();
431-
#endif
432-
433432
//! emit initializationCompleted signal
434433
//! @note added in 1.6
435434
void completeInitialization();
@@ -439,6 +438,13 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
439438
QList<QgsDecorationItem*> decorationItems() { return mDecorationItems; }
440439
void addDecorationItem( QgsDecorationItem* item ) { mDecorationItems.append( item ); }
441440

441+
#ifdef Q_OS_WIN
442+
//! ugly hack
443+
void skipNextContextMenuEvent();
444+
445+
static LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo );
446+
#endif
447+
442448
public slots:
443449
//! Zoom to full extent
444450
void zoomFull();

src/app/qgisappinterface.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class QgisApp;
3636
* Only those functions "exposed" by QgisInterface can be called from within a
3737
* plugin.
3838
*/
39-
class QgisAppInterface : public QgisInterface
39+
class APP_EXPORT QgisAppInterface : public QgisInterface
4040
{
4141
Q_OBJECT
4242

src/app/qgisappstylesheet.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/** @class QgisAppStyleSheet
2626
* @brief Adjustable stylesheet for the Qgis application
2727
*/
28-
class QgisAppStyleSheet: public QObject
28+
class APP_EXPORT QgisAppStyleSheet: public QObject
2929
{
3030
Q_OBJECT
3131

src/app/qgsabout.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include "ui_qgsabout.h"
2121

22-
class QgsAbout : public QDialog, private Ui::QgsAbout
22+
class APP_EXPORT QgsAbout : public QDialog, private Ui::QgsAbout
2323
{
2424
Q_OBJECT
2525
public:

src/app/qgsaddattrdialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class QgsVectorLayer;
2626

27-
class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
27+
class APP_EXPORT QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
2828
{
2929
Q_OBJECT
3030
public:

src/app/qgsaddjoindialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "ui_qgsaddjoindialogbase.h"
2222
class QgsVectorLayer;
2323

24-
class QgsAddJoinDialog: public QDialog, private Ui::QgsAddJoinDialogBase
24+
class APP_EXPORT QgsAddJoinDialog: public QDialog, private Ui::QgsAddJoinDialogBase
2525
{
2626
Q_OBJECT
2727
public:

src/app/qgsaddtaborgroup.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class QTreeWidgetItem;
2626
class QgsVectorLayer;
2727

28-
class QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroupBase
28+
class APP_EXPORT QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroupBase
2929
{
3030
Q_OBJECT
3131

src/app/qgsannotationwidget.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class QgsMarkerSymbolV2;
2525

2626
/**A configuration widget to configure the annotation item properties. Usually embedded by QgsAnnotationItem
2727
subclass configuration dialogs*/
28-
class QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase
28+
class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase
2929
{
3030
Q_OBJECT
3131
public:

0 commit comments

Comments
 (0)