From 86add3bb85312d227d6f9d8b9429d4c6ec5953f3 Mon Sep 17 00:00:00 2001 From: david-beinder Date: Fri, 4 Jun 2021 21:41:40 +0200 Subject: [PATCH] Fix MSVC C4312 warnings when casting 32bit ints to pointer types on 64bit builds --- 3d-viewer/3d_rendering/legacy/3d_model.cpp | 6 ++++-- common/dialogs/dialog_grid_settings.cpp | 2 +- common/eda_draw_frame.cpp | 4 ++-- pcbnew/tools/edit_tool.cpp | 3 ++- pcbnew/widgets/appearance_controls.cpp | 17 ++++++++++------- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/3d-viewer/3d_rendering/legacy/3d_model.cpp b/3d-viewer/3d_rendering/legacy/3d_model.cpp index db112c828e..17fa2710be 100644 --- a/3d-viewer/3d_rendering/legacy/3d_model.cpp +++ b/3d-viewer/3d_rendering/legacy/3d_model.cpp @@ -455,7 +455,8 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria } glDrawElements( GL_TRIANGLES, mat.m_render_idx_count, m_index_buffer_type, - reinterpret_cast( mat.m_render_idx_buffer_offset ) ); + reinterpret_cast( + static_cast( mat.m_render_idx_buffer_offset ) ) ); } } @@ -509,6 +510,7 @@ void MODEL_3D::DrawBboxes() const ? sizeof( GLushort ) : sizeof( GLuint ); glDrawElements( GL_LINES, bbox_idx_count * m_meshes_bbox.size(), m_bbox_index_buffer_type, - reinterpret_cast( bbox_idx_count * idx_size ) ); + reinterpret_cast( + static_cast( bbox_idx_count * idx_size ) ) ); } diff --git a/common/dialogs/dialog_grid_settings.cpp b/common/dialogs/dialog_grid_settings.cpp index 0f0b265f4e..59bd4050bd 100644 --- a/common/dialogs/dialog_grid_settings.cpp +++ b/common/dialogs/dialog_grid_settings.cpp @@ -123,7 +123,7 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow() mgr->ResetTools( TOOL_BASE::MODEL_RELOAD ); // Notify GAL - mgr->RunAction( ACTIONS::gridPreset, true, gridCfg.last_size_idx ); + mgr->RunAction( ACTIONS::gridPreset, true, static_cast( gridCfg.last_size_idx ) ); mgr->RunAction( ACTIONS::gridSetOrigin, true, new VECTOR2D( m_parent->GetGridOrigin() ) ); m_parent->UpdateGridSelectBox(); diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index fde90e5dac..15ec11a96d 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -348,7 +348,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) } else { - m_toolManager->RunAction( ACTIONS::gridPreset, true, idx ); + m_toolManager->RunAction( ACTIONS::gridPreset, true, static_cast( idx ) ); } UpdateStatusBar(); @@ -453,7 +453,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) ) return; - m_toolManager->RunAction( "common.Control.zoomPreset", true, id ); + m_toolManager->RunAction( ACTIONS::zoomPreset, true, static_cast( id ) ); UpdateStatusBar(); m_canvas->Refresh(); } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index b9e505ad0e..c6ff78e451 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -253,7 +253,8 @@ bool EDIT_TOOL::invokeInlineRouter( int aDragMode ) if( theRouter->CanInlineDrag( aDragMode ) ) { - m_toolMgr->RunAction( PCB_ACTIONS::routerInlineDrag, true, aDragMode ); + m_toolMgr->RunAction( PCB_ACTIONS::routerInlineDrag, true, + static_cast( aDragMode ) ); return true; } diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index dac6eed5f6..dbfe656374 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -302,7 +302,7 @@ void NET_GRID_TABLE::HideOtherNets( const NET_GRID_ENTRY& aNet ) void NET_GRID_TABLE::updateNetVisibility( const NET_GRID_ENTRY& aNet ) { const TOOL_ACTION& action = aNet.visible ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet; - m_frame->GetToolManager()->RunAction( action, true, aNet.code ); + m_frame->GetToolManager()->RunAction( action, true, static_cast( aNet.code ) ); } @@ -2488,21 +2488,24 @@ void APPEARANCE_CONTROLS::onNetContextMenu( wxCommandEvent& aEvent ) case ID_HIGHLIGHT_NET: { - m_frame->GetToolManager()->RunAction( PCB_ACTIONS::highlightNet, true, net.code ); + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::highlightNet, true, + static_cast( net.code ) ); m_frame->GetCanvas()->Refresh(); break; } case ID_SELECT_NET: { - m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectNet, true, net.code ); + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectNet, true, + static_cast( net.code ) ); m_frame->GetCanvas()->Refresh(); break; } case ID_DESELECT_NET: { - m_frame->GetToolManager()->RunAction( PCB_ACTIONS::deselectNet, true, net.code ); + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::deselectNet, true, + static_cast( net.code ) ); m_frame->GetCanvas()->Refresh(); break; } @@ -2553,7 +2556,7 @@ void APPEARANCE_CONTROLS::showNetclass( const wxString& aClassName, bool aShow ) { if( net->GetNetClass() == defaultClass ) { - manager->RunAction( action, true, net->GetNetCode() ); + manager->RunAction( action, true, static_cast( net->GetNetCode() ) ); int row = m_netsTable->GetRowByNetcode( net->GetNetCode() ); @@ -2571,7 +2574,7 @@ void APPEARANCE_CONTROLS::showNetclass( const wxString& aClassName, bool aShow ) if( NETINFO_ITEM* net = nets.GetNetItem( member ) ) { int code = net->GetNetCode(); - manager->RunAction( action, true, code ); + manager->RunAction( action, true, static_cast( code ) ); int row = m_netsTable->GetRowByNetcode( code ); @@ -2746,7 +2749,7 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent ) if( !aItem ) return; - int code = aItem->GetNetCode(); + intptr_t code = static_cast( aItem->GetNetCode() ); m_frame->GetToolManager()->RunAction( action, true, code ); } ); }