diff --git a/3d-viewer/3d_cache/3d_cache.cpp b/3d-viewer/3d_cache/3d_cache.cpp index a2d22d6036..8ed60b3ce2 100644 --- a/3d-viewer/3d_cache/3d_cache.cpp +++ b/3d-viewer/3d_cache/3d_cache.cpp @@ -3,6 +3,7 @@ * * Copyright (C) 2015-2016 Cirilo Bernardo * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2022 CERN * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -194,19 +195,6 @@ S3D_CACHE::S3D_CACHE() S3D_CACHE::~S3D_CACHE() { - FlushCache(); - - // We'll delete ".3dc" cache files older than this many days - int clearCacheInterval = 0; - - if( Pgm().GetCommonSettings() ) - clearCacheInterval = Pgm().GetCommonSettings()->m_System.clear_3d_cache_interval; - - // An interval of zero means the user doesn't want to ever clear the cache - - if( clearCacheInterval > 0 ) - CleanCacheDir( clearCacheInterval ); - delete m_FNResolver; delete m_Plugins; } @@ -710,6 +698,29 @@ void S3D_CACHE::CleanCacheDir( int aNumDaysOld ) } +void PROJECT::Cleanup3DCache() +{ + std::lock_guard lock( mutex3D_cacheManager ); + + // Get the existing cache from the project + S3D_CACHE* cache = dynamic_cast( GetElem( ELEM_3DCACHE ) ); + + if( cache ) + { + // We'll delete ".3dc" cache files older than this many days + int clearCacheInterval = 0; + + if( Pgm().GetCommonSettings() ) + clearCacheInterval = Pgm().GetCommonSettings()->m_System.clear_3d_cache_interval; + + // An interval of zero means the user doesn't want to ever clear the cache + + if( clearCacheInterval > 0 ) + cache->CleanCacheDir( clearCacheInterval ); + } +} + + S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir ) { std::lock_guard lock( mutex3D_cacheManager ); diff --git a/include/project.h b/include/project.h index dadb01595a..73b90a38c7 100644 --- a/include/project.h +++ b/include/project.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2022 CERN * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -281,6 +282,8 @@ public: */ S3D_CACHE* Get3DCacheManager( bool updateProjDir = false ); + void Cleanup3DCache(); + /// Accessor for 3D path resolver FILENAME_RESOLVER* Get3DFilenameResolver(); #endif diff --git a/include/units_provider.h b/include/units_provider.h index 48401fba8d..9d86fc8859 100644 --- a/include/units_provider.h +++ b/include/units_provider.h @@ -36,6 +36,9 @@ public: m_userUnits( aUnits ) {} + virtual ~UNITS_PROVIDER() + {} + EDA_UNITS GetUserUnits() const { return m_userUnits; } void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; } diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index aa778ac861..77aa53f7a1 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -5,6 +5,7 @@ * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2011 Wayne Stambaugh * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2022 CERN * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -104,6 +105,10 @@ bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent ) if( viewer3D ) viewer3D->Close( true ); + // Similarly, wxConvBrokenFileNames uses some statically allocated variables that make it + // crash when run later from a d'tor. + Prj().Cleanup3DCache(); + return true; }