Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make qgis_app a shared library and fix some more stl warnings with msvc
  • Loading branch information
jef-n committed Sep 6, 2013
1 parent 1632730 commit 0a1d44f
Show file tree
Hide file tree
Showing 128 changed files with 248 additions and 237 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -494,6 +494,7 @@ ADD_DEFINITIONS("-DCORE_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DGUI_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DPYTHON_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DANALYSIS_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DAPP_EXPORT=${DLLIMPORT}")

#############################################################
# user-changeable settings which can be used to customize
Expand Down
8 changes: 4 additions & 4 deletions python/core/composer/qgsatlascomposition.sip
Expand Up @@ -50,19 +50,19 @@ public:
QString featureFilter() const;
void setFeatureFilter( const QString& expression );

size_t sortKeyAttributeIndex() const;
void setSortKeyAttributeIndex( size_t idx );
int sortKeyAttributeIndex() const;
void setSortKeyAttributeIndex( int idx );

/** Begins the rendering. */
void beginRender();
/** Ends the rendering. Restores original extent */
void endRender();

/** Returns the number of features in the coverage layer */
size_t numFeatures() const;
int numFeatures() const;

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

/** Returns the current filename. Must be called after prepareForFeature( i ) */
const QString& currentFilename() const;
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsgeometry.sip
Expand Up @@ -61,7 +61,7 @@ class QgsGeometry
/**
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
This class will take ownership of the buffer.
*/
*/
void fromWkb( unsigned char * wkb /Array/, size_t length /ArraySize/ );
%MethodCode
// create copy of Python's string and pass it to fromWkb()
Expand Down
10 changes: 5 additions & 5 deletions python/core/qgsprojectproperty.sip
Expand Up @@ -13,7 +13,7 @@ class QgsProperty
@param tabs is number of tabs to print; used for pretty-printing
hierarchy
*/
virtual void dump( size_t tabs = 0 ) const = 0;
virtual void dump( int tabs = 0 ) const = 0;

/** returns true if is a QgsPropertyKey */
virtual bool isKey() const = 0;
Expand Down Expand Up @@ -90,15 +90,15 @@ class QgsPropertyValue : QgsProperty
*/
bool isLeaf() const;

void dump( size_t tabs = 0 ) const;
void dump( int tabs = 0 ) const;

bool readXML( QDomNode & keyNode );

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

size_t count() const;
int count() const;

/** return keys that do not contain other keys

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


void dump( size_t tabs = 0 ) const;
void dump( int tabs = 0 ) const;

bool readXML( QDomNode & keyNode );

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

/// how many elements are contained within this one?
size_t count() const;
int count() const;

/// Does this property not have any subkeys or values?
/* virtual */ bool isEmpty() const;
Expand Down
9 changes: 3 additions & 6 deletions python/core/raster/qgsrasterbandstats.sip
Expand Up @@ -30,12 +30,9 @@ class QgsRasterBandStats
/** \brief The gdal band number (starts at 1)*/
int bandNumber;

/** Color table */
// QList<QgsColorRampShader::ColorRampItem> colorTable;

/** \brief The number of cells in the band. Equivalent to height x width.
* TODO: check if NO_DATA are excluded!*/
int elementCount;
/** \brief The number of not no data cells in the band. */
// TODO: check if no data are excluded in stats calculation
size_t elementCount;

/** \brief The maximum cell value in the raster band. NO_DATA values
* are ignored. This does not use the gdal GetMaximmum function. */
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/CMakeLists.txt
Expand Up @@ -142,9 +142,9 @@ INCLUDE_DIRECTORIES(

IF (WIN32)
IF (MSVC)
ADD_DEFINITIONS("-DANALYSIS_EXPORT=__declspec(dllexport)")
ADD_DEFINITIONS("-DANALYSIS_EXPORT=${DLLEXPORT}")
ELSE (MSVC)
ADD_DEFINITIONS("-UANALYSIS_EXPORT \"-DANALYSIS_EXPORT=__declspec(dllexport)\"")
ADD_DEFINITIONS("-UANALYSIS_EXPORT \"-DANALYSIS_EXPORT=${DLLEXPORT}\"")
ENDIF (MSVC)
ENDIF (WIN32)

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/qgsgeometryanalyzer.cpp
Expand Up @@ -737,7 +737,7 @@ void QgsGeometryAnalyzer::dissolveFeature( QgsFeature& f, int nProcessedFeatures

if ( nProcessedFeatures == 0 )
{
int geomSize = featureGeometry->wkbSize();
size_t geomSize = featureGeometry->wkbSize();
*dissolveGeometry = new QgsGeometry();
unsigned char* wkb = new unsigned char[geomSize];
memcpy( wkb, featureGeometry->asWkb(), geomSize );
Expand Down
13 changes: 11 additions & 2 deletions src/app/CMakeLists.txt
Expand Up @@ -456,8 +456,16 @@ ELSE (ANDROID)
ADD_EXECUTABLE(${QGIS_APP_NAME} MACOSX_BUNDLE WIN32 main.cpp ${QGIS_APP_SRCS} ${QGIS_APP_MOC_SRCS} ${IMAGE_RCC_SRCS} ${TEST_RCC_SRCS})
ENDIF (ANDROID)

IF (WIN32)
IF (MSVC)
ADD_DEFINITIONS("-DAPP_EXPORT=${DLLEXPORT}")
ELSE (MSVC)
ADD_DEFINITIONS("-UAPP_EXPORT \"-DAPP_EXPORT=${DLLEXPORT}\"")
ENDIF (MSVC)
ENDIF (WIN32)

# shared library used by tests - TODO: use it also for qgis executable?
ADD_LIBRARY(qgis_app STATIC ${QGIS_APP_SRCS} ${QGIS_APP_MOC_SRCS} ${QGIS_APP_HDRS} ${QGIS_APP_MOC_HDRS} ${IMAGE_RCC_SRCS})
ADD_LIBRARY(qgis_app SHARED ${QGIS_APP_SRCS} ${QGIS_APP_MOC_SRCS} ${QGIS_APP_HDRS} ${QGIS_APP_MOC_HDRS} ${IMAGE_RCC_SRCS})

TARGET_LINK_LIBRARIES(qgis_app
${QWT_LIBRARY}
Expand Down Expand Up @@ -498,6 +506,7 @@ ENDIF (ANDROID)
IF(WIN32)
ADD_DEFINITIONS(-DQWT_DLL)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} DbgHelp)
TARGET_LINK_LIBRARIES(qgis_app DbgHelp)
ENDIF(WIN32)

IF (APPLE)
Expand All @@ -511,7 +520,7 @@ ENDIF(APPLE)

IF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
FIND_LIBRARY(EXECINFO_LIBRARY NAMES execinfo)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${EXECINFO_LIBRARY})
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${EXECINFO_LIBRARY})
ENDIF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")

IF (POSTGRES_FOUND)
Expand Down
45 changes: 1 addition & 44 deletions src/app/main.cpp
Expand Up @@ -149,49 +149,6 @@ bool bundleclicked( int argc, char *argv[] )
return ( argc > 1 && memcmp( argv[1], "-psn_", 5 ) == 0 );
}

#ifdef Q_OS_WIN
LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
QString dumpName = QDir::toNativeSeparators(
QString( "%1\\qgis-%2-%3-%4-%5.dmp" )
.arg( QDir::tempPath() )
.arg( QDateTime::currentDateTime().toString( "yyyyMMdd-hhmmss" ) )
.arg( GetCurrentProcessId() )
.arg( GetCurrentThreadId() )
.arg( QGis::QGIS_DEV_VERSION )
);

QString msg;
HANDLE hDumpFile = CreateFile( dumpName.toLocal8Bit(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0 );
if ( hDumpFile != INVALID_HANDLE_VALUE )
{
MINIDUMP_EXCEPTION_INFORMATION ExpParam;
ExpParam.ThreadId = GetCurrentThreadId();
ExpParam.ExceptionPointers = ExceptionInfo;
ExpParam.ClientPointers = TRUE;

if ( MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpWithDataSegs, ExceptionInfo ? &ExpParam : NULL, NULL, NULL ) )
{
msg = QObject::tr( "minidump written to %1" ).arg( dumpName );
}
else
{
msg = QObject::tr( "writing of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
}

CloseHandle( hDumpFile );
}
else
{
msg = QObject::tr( "creation of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
}

QMessageBox::critical( 0, QObject::tr( "Crash dumped" ), msg );

return EXCEPTION_EXECUTE_HANDLER;
}
#endif

void myPrint( const char *fmt, ... )
{
va_list ap;
Expand Down Expand Up @@ -421,7 +378,7 @@ int main( int argc, char *argv[] )
#endif

#ifdef Q_OS_WIN
SetUnhandledExceptionFilter( qgisCrashDump );
SetUnhandledExceptionFilter( QgisApp::qgisCrashDump );
#endif

// initialize random number seed
Expand Down
49 changes: 45 additions & 4 deletions src/app/qgisapp.cpp
Expand Up @@ -277,10 +277,11 @@ extern "C"

#include "qgspythonutils.h"

#ifndef WIN32
#ifndef Q_OS_WIN
#include <dlfcn.h>
#else
#include <windows.h>
#include <DbgHelp.h>
#endif

#ifdef HAVE_TOUCH
Expand Down Expand Up @@ -8864,14 +8865,11 @@ void QgisApp::keyPressEvent( QKeyEvent * e )
{
stopRendering();
}
#if 0
#if defined(Q_OS_WIN)&& defined(QGISDEBUG)
else if ( e->key() == Qt::Key_Backslash && e->modifiers() & Qt::ControlModifier )
{
extern LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo );
qgisCrashDump( 0 );
}
#endif
#endif
else
{
Expand Down Expand Up @@ -9403,3 +9401,46 @@ void QgisApp::tapAndHoldTriggered( QTapAndHoldGesture *gesture )
}
}
#endif

#ifdef Q_OS_WIN
LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
QString dumpName = QDir::toNativeSeparators(
QString( "%1\\qgis-%2-%3-%4-%5.dmp" )
.arg( QDir::tempPath() )
.arg( QDateTime::currentDateTime().toString( "yyyyMMdd-hhmmss" ) )
.arg( GetCurrentProcessId() )
.arg( GetCurrentThreadId() )
.arg( QGis::QGIS_DEV_VERSION )
);

QString msg;
HANDLE hDumpFile = CreateFile( dumpName.toLocal8Bit(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0 );
if ( hDumpFile != INVALID_HANDLE_VALUE )
{
MINIDUMP_EXCEPTION_INFORMATION ExpParam;
ExpParam.ThreadId = GetCurrentThreadId();
ExpParam.ExceptionPointers = ExceptionInfo;
ExpParam.ClientPointers = TRUE;

if ( MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpWithDataSegs, ExceptionInfo ? &ExpParam : NULL, NULL, NULL ) )
{
msg = QObject::tr( "minidump written to %1" ).arg( dumpName );
}
else
{
msg = QObject::tr( "writing of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
}

CloseHandle( hDumpFile );
}
else
{
msg = QObject::tr( "creation of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
}

QMessageBox::critical( 0, QObject::tr( "Crash dumped" ), msg );

return EXCEPTION_EXECUTE_HANDLER;
}
#endif
18 changes: 12 additions & 6 deletions src/app/qgisapp.h
Expand Up @@ -100,10 +100,14 @@ class QgsTileScaleWidget;
#include <QTapAndHoldGesture>
#endif

#ifdef Q_OS_WIN
#include <windows.h>
#endif

/*! \class QgisApp
* \brief Main window for the Qgis application
*/
class QgisApp : public QMainWindow, private Ui::MainWindow
class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
{
Q_OBJECT
public:
Expand Down Expand Up @@ -425,11 +429,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
* @note added in 1.9 */
int messageTimeout();

#ifdef Q_OS_WIN
//! ugly hack
void skipNextContextMenuEvent();
#endif

//! emit initializationCompleted signal
//! @note added in 1.6
void completeInitialization();
Expand All @@ -439,6 +438,13 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QList<QgsDecorationItem*> decorationItems() { return mDecorationItems; }
void addDecorationItem( QgsDecorationItem* item ) { mDecorationItems.append( item ); }

#ifdef Q_OS_WIN
//! ugly hack
void skipNextContextMenuEvent();

static LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo );
#endif

public slots:
//! Zoom to full extent
void zoomFull();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.h
Expand Up @@ -36,7 +36,7 @@ class QgisApp;
* Only those functions "exposed" by QgisInterface can be called from within a
* plugin.
*/
class QgisAppInterface : public QgisInterface
class APP_EXPORT QgisAppInterface : public QgisInterface
{
Q_OBJECT

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappstylesheet.h
Expand Up @@ -25,7 +25,7 @@
/** @class QgisAppStyleSheet
* @brief Adjustable stylesheet for the Qgis application
*/
class QgisAppStyleSheet: public QObject
class APP_EXPORT QgisAppStyleSheet: public QObject
{
Q_OBJECT

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsabout.h
Expand Up @@ -19,7 +19,7 @@

#include "ui_qgsabout.h"

class QgsAbout : public QDialog, private Ui::QgsAbout
class APP_EXPORT QgsAbout : public QDialog, private Ui::QgsAbout
{
Q_OBJECT
public:
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsaddattrdialog.h
Expand Up @@ -24,7 +24,7 @@

class QgsVectorLayer;

class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
class APP_EXPORT QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
{
Q_OBJECT
public:
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsaddjoindialog.h
Expand Up @@ -21,7 +21,7 @@
#include "ui_qgsaddjoindialogbase.h"
class QgsVectorLayer;

class QgsAddJoinDialog: public QDialog, private Ui::QgsAddJoinDialogBase
class APP_EXPORT QgsAddJoinDialog: public QDialog, private Ui::QgsAddJoinDialogBase
{
Q_OBJECT
public:
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsaddtaborgroup.h
Expand Up @@ -25,7 +25,7 @@
class QTreeWidgetItem;
class QgsVectorLayer;

class QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroupBase
class APP_EXPORT QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroupBase
{
Q_OBJECT

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsannotationwidget.h
Expand Up @@ -25,7 +25,7 @@ class QgsMarkerSymbolV2;

/**A configuration widget to configure the annotation item properties. Usually embedded by QgsAnnotationItem
subclass configuration dialogs*/
class QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase
class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase
{
Q_OBJECT
public:
Expand Down

0 comments on commit 0a1d44f

Please sign in to comment.