Coverity report and compile warning fixes
This commit is contained in:
parent
42eb063697
commit
97a4034d95
|
@ -40,7 +40,7 @@ DIALOG_PCM_PROGRESS::DIALOG_PCM_PROGRESS( wxWindow* parent, bool aShowDownloadSe
|
|||
m_downloadGauge->SetRange( GAUGE_RANGE );
|
||||
m_overallGauge->SetRange( GAUGE_RANGE );
|
||||
|
||||
m_overallPhases = 1;
|
||||
SetOverallProgressPhases( 1 );
|
||||
|
||||
if( !aShowDownloadSection )
|
||||
m_panelDownload->Hide();
|
||||
|
|
|
@ -35,9 +35,10 @@ struct PACKAGE_VIEW_DATA
|
|||
wxString repository_id;
|
||||
wxString repository_name;
|
||||
wxString current_version;
|
||||
PACKAGE_VIEW_DATA( const PCM_PACKAGE aPackage ) : package( std::move( aPackage ) ){};
|
||||
PACKAGE_VIEW_DATA( const PCM_PACKAGE aPackage ) :
|
||||
package( std::move( aPackage ) ), bitmap( nullptr ), state( PPS_INSTALLED ){};
|
||||
PACKAGE_VIEW_DATA( const PCM_INSTALLATION_ENTRY& aEntry ) :
|
||||
package( std::move( aEntry.package ) )
|
||||
package( std::move( aEntry.package ) ), bitmap( nullptr )
|
||||
{
|
||||
state = PPS_INSTALLED;
|
||||
repository_id = aEntry.repository_id;
|
||||
|
|
|
@ -140,14 +140,16 @@ PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER( wxWindow* aParent ) : m_dialog(
|
|||
|
||||
// wxFileModificationTime bugs out on windows for directories
|
||||
wxStructStat stat;
|
||||
wxStat( subdir_file.GetFullPath(), &stat );
|
||||
int stat_code = wxStat( subdir_file.GetFullPath(), &stat );
|
||||
|
||||
entry.package.name = subdir;
|
||||
entry.package.identifier = actual_package_id;
|
||||
entry.current_version = "0.0";
|
||||
entry.install_timestamp = stat.st_mtime;
|
||||
entry.repository_name = wxT( "<unknown>" );
|
||||
|
||||
if( stat_code == 0 )
|
||||
entry.install_timestamp = stat.st_mtime;
|
||||
|
||||
m_installed.emplace( actual_package_id, entry );
|
||||
}
|
||||
|
||||
|
@ -649,18 +651,25 @@ PLUGIN_CONTENT_MANAGER::~PLUGIN_CONTENT_MANAGER()
|
|||
{
|
||||
// Save current installed packages list.
|
||||
|
||||
nlohmann::json js;
|
||||
js["packages"] = nlohmann::json::array();
|
||||
|
||||
for( const auto& entry : m_installed )
|
||||
try
|
||||
{
|
||||
js["packages"].emplace_back( entry.second );
|
||||
nlohmann::json js;
|
||||
js["packages"] = nlohmann::json::array();
|
||||
|
||||
for( const auto& entry : m_installed )
|
||||
{
|
||||
js["packages"].emplace_back( entry.second );
|
||||
}
|
||||
|
||||
wxFileName f( SETTINGS_MANAGER::GetUserSettingsPath(), "installed_packages.json" );
|
||||
std::ofstream stream( f.GetFullPath().ToUTF8() );
|
||||
|
||||
stream << std::setw( 4 ) << js << std::endl;
|
||||
}
|
||||
catch( nlohmann::detail::exception& )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
|
||||
wxFileName f( SETTINGS_MANAGER::GetUserSettingsPath(), "installed_packages.json" );
|
||||
std::ofstream stream( f.GetFullPath().ToUTF8() );
|
||||
|
||||
stream << std::setw( 4 ) << js << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -717,8 +726,8 @@ int PLUGIN_CONTENT_MANAGER::GetPackageSearchRank( const PCM_PACKAGE& aPackage,
|
|||
rank += 500 * find_term_matches( aPackage.name );
|
||||
|
||||
// Match on tags
|
||||
for( const wxString& tag : aPackage.tags )
|
||||
rank += 100 * find_term_matches( tag );
|
||||
for( const std::string& tag : aPackage.tags )
|
||||
rank += 100 * find_term_matches( wxString( tag ) );
|
||||
|
||||
// Match on package description
|
||||
rank += 10 * find_term_matches( aPackage.description );
|
||||
|
|
|
@ -333,7 +333,7 @@ void PCM_TASK_MANAGER::InstallFromFile( wxWindow* aParent, const wxString& aFile
|
|||
return;
|
||||
}
|
||||
|
||||
m_reporter = new DIALOG_PCM_PROGRESS( aParent, false );
|
||||
m_reporter = std::make_unique<DIALOG_PCM_PROGRESS>( aParent, false );
|
||||
m_reporter->Show();
|
||||
|
||||
if( extract( aFilePath, package.identifier ) )
|
||||
|
@ -342,6 +342,7 @@ void PCM_TASK_MANAGER::InstallFromFile( wxWindow* aParent, const wxString& aFile
|
|||
m_reporter->SetFinished();
|
||||
m_reporter->ShowModal();
|
||||
m_reporter->Destroy();
|
||||
m_reporter.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -390,7 +391,7 @@ void PCM_TASK_MANAGER::Uninstall( const PCM_PACKAGE& aPackage )
|
|||
|
||||
void PCM_TASK_MANAGER::RunQueue( wxWindow* aParent )
|
||||
{
|
||||
m_reporter = new DIALOG_PCM_PROGRESS( aParent );
|
||||
m_reporter = std::make_unique<DIALOG_PCM_PROGRESS>( aParent );
|
||||
|
||||
m_reporter->SetOverallProgressPhases( m_download_queue.size() + m_install_queue.size() );
|
||||
m_reporter->Show();
|
||||
|
@ -460,6 +461,7 @@ void PCM_TASK_MANAGER::RunQueue( wxWindow* aParent )
|
|||
|
||||
m_reporter->ShowModal();
|
||||
m_reporter->Destroy();
|
||||
m_reporter.reset();
|
||||
|
||||
download_thread.join();
|
||||
install_thread.join();
|
||||
|
|
|
@ -129,7 +129,7 @@ private:
|
|||
*/
|
||||
void deletePackageDirectories( const wxString& aPackageId );
|
||||
|
||||
DIALOG_PCM_PROGRESS* m_reporter;
|
||||
std::unique_ptr<DIALOG_PCM_PROGRESS> m_reporter;
|
||||
SYNC_QUEUE<PCM_TASK> m_download_queue;
|
||||
SYNC_QUEUE<PCM_TASK> m_install_queue;
|
||||
std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
|
||||
|
|
Loading…
Reference in New Issue