Skip to content

Commit

Permalink
Rely on QObject parenting
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Apr 16, 2024
1 parent 3e75141 commit 8bb8073
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ QgisMobileapp::QgisMobileapp( QgsApplication *app, QObject *parent )
palette.setColor( QPalette::LinkVisited, QColor( 128, 204, 40 ) );
app->setPalette( palette );

mMessageLogModel = std::make_unique<MessageLogModel>( this );
mMessageLogModel = new MessageLogModel( this );

QSettings settings;
if ( PlatformUtilities::instance()->capabilities() & PlatformUtilities::AdjustBrightness )
Expand Down Expand Up @@ -267,10 +267,10 @@ QgisMobileapp::QgisMobileapp( QgsApplication *app, QObject *parent )
mLocalFilesImageProvider = new LocalFilesImageProvider();
mProjectsImageProvider = new ProjectsImageProvider();

mBookmarkModel = std::make_unique<BookmarkModel>( QgsApplication::bookmarkManager(), mProject->bookmarkManager(), nullptr );
mDrawingTemplateModel = std::make_unique<DrawingTemplateModel>( this );
mBookmarkModel = new BookmarkModel( QgsApplication::bookmarkManager(), mProject->bookmarkManager(), this );
mDrawingTemplateModel = new DrawingTemplateModel( this );

mPluginManager = std::make_unique<PluginManager>( this );
mPluginManager = new PluginManager( this );

// cppcheck-suppress leakReturnValNotUsed
initDeclarative();
Expand Down Expand Up @@ -543,7 +543,7 @@ void QgisMobileapp::initDeclarative()
rootContext()->setContextProperty( "mouseDoubleClickInterval", QApplication::styleHints()->mouseDoubleClickInterval() );
rootContext()->setContextProperty( "qgisProject", mProject );
rootContext()->setContextProperty( "iface", mIface );
rootContext()->setContextProperty( "pluginManager", mPluginManager.get() );
rootContext()->setContextProperty( "pluginManager", mPluginManager );
rootContext()->setContextProperty( "settings", &mSettings );
rootContext()->setContextProperty( "appVersion", qfield::appVersion );
rootContext()->setContextProperty( "appVersionStr", qfield::appVersionStr );
Expand All @@ -553,12 +553,12 @@ void QgisMobileapp::initDeclarative()
rootContext()->setContextProperty( "CrsFactory", QVariant::fromValue<QgsCoordinateReferenceSystem>( mCrsFactory ) );
rootContext()->setContextProperty( "UnitTypes", QVariant::fromValue<QgsUnitTypes>( mUnitTypes ) );
rootContext()->setContextProperty( "ExifTools", QVariant::fromValue<QgsExifTools>( mExifTools ) );
rootContext()->setContextProperty( "bookmarkModel", mBookmarkModel.get() );
rootContext()->setContextProperty( "bookmarkModel", mBookmarkModel );
rootContext()->setContextProperty( "gpkgFlusher", mGpkgFlusher.get() );
rootContext()->setContextProperty( "layerObserver", mLayerObserver.get() );
rootContext()->setContextProperty( "featureHistory", mFeatureHistory.get() );
rootContext()->setContextProperty( "messageLogModel", mMessageLogModel.get() );
rootContext()->setContextProperty( "drawingTemplateModel", mDrawingTemplateModel.get() );
rootContext()->setContextProperty( "messageLogModel", mMessageLogModel );
rootContext()->setContextProperty( "drawingTemplateModel", mDrawingTemplateModel );

rootContext()->setContextProperty( "qfieldAuthRequestHandler", mAuthRequestHandler );

Expand Down
8 changes: 4 additions & 4 deletions src/core/qgismobileapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ class QFIELD_CORE_EXPORT QgisMobileapp : public QQmlApplicationEngine
std::unique_ptr<FeatureHistory> mFeatureHistory;
QFieldAppAuthRequestHandler *mAuthRequestHandler = nullptr;

std::unique_ptr<BookmarkModel> mBookmarkModel;
std::unique_ptr<DrawingTemplateModel> mDrawingTemplateModel;
std::unique_ptr<MessageLogModel> mMessageLogModel;
BookmarkModel *mBookmarkModel = nullptr;
DrawingTemplateModel *mDrawingTemplateModel = nullptr;
MessageLogModel *mMessageLogModel = nullptr;

std::unique_ptr<PluginManager> mPluginManager;
PluginManager *mPluginManager = nullptr;

// Dummy objects. We are not able to call static functions from QML, so we need something here.
QgsCoordinateReferenceSystem mCrsFactory;
Expand Down

0 comments on commit 8bb8073

Please sign in to comment.