From 92c2ddf77a2265bc77d43d34e989b8236d305766 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 2 Feb 2024 12:47:34 -0500 Subject: [PATCH] Do not parent dialogs to non top level windows in panels or widgets. --- 3d-viewer/dialogs/appearance_controls_3D.cpp | 10 ++-- common/dialogs/panel_color_settings.cpp | 5 +- common/dialogs/panel_grid_settings.cpp | 17 +++++-- common/dialogs/panel_hotkeys_editor.cpp | 10 ++-- common/dialogs/panel_image_editor.cpp | 16 +++--- common/dialogs/panel_setup_netclasses.cpp | 9 ++-- common/dialogs/panel_text_variables.cpp | 12 +++-- common/widgets/wx_html_report_panel.cpp | 3 +- .../dialogs/panel_eeschema_color_settings.cpp | 5 +- eeschema/dialogs/panel_setup_buses.cpp | 6 ++- eeschema/dialogs/panel_sym_lib_table.cpp | 29 ++++++++--- include/confirm.h | 5 +- kicad/import_project.cpp | 2 +- kicad/pcm/dialogs/panel_packages_view.cpp | 11 ++-- kicad/project_tree_item.cpp | 2 +- kicad/project_tree_pane.cpp | 51 +++++++++++-------- .../dialogs/properties_frame.cpp | 2 +- .../calculator_panels/panel_regulator.cpp | 4 +- .../dialogs/dialog_regulator_form.cpp | 4 +- .../dialogs/dialog_regulator_form.h | 4 +- pcbnew/dialogs/panel_fp_editor_defaults.cpp | 5 +- pcbnew/dialogs/panel_fp_lib_table.cpp | 20 +++++--- .../dialogs/panel_pcbnew_action_plugins.cpp | 2 +- pcbnew/dialogs/panel_setup_layers.cpp | 27 ++++++---- pcbnew/dialogs/panel_setup_rules.cpp | 4 +- .../dialogs/panel_setup_text_and_graphics.cpp | 3 +- pcbnew/widgets/appearance_controls.cpp | 12 +++-- 27 files changed, 176 insertions(+), 104 deletions(-) diff --git a/3d-viewer/dialogs/appearance_controls_3D.cpp b/3d-viewer/dialogs/appearance_controls_3D.cpp index b0e97168d3..f4af6f696c 100644 --- a/3d-viewer/dialogs/appearance_controls_3D.cpp +++ b/3d-viewer/dialogs/appearance_controls_3D.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2023 CERN - * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2023-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -645,7 +645,8 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent ) } else if( index == count - 2 ) { - wxTextEntryDialog dlg( this, _( "Layer preset name:" ), _( "Save Layer Preset" ) ); + wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "Layer preset name:" ), + _( "Save Layer Preset" ) ); if( dlg.ShowModal() != wxID_OK ) { @@ -660,7 +661,7 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent ) if( LAYER_PRESET_3D* preset = cfg->FindPreset( name ) ) { - if( !IsOK( this, _( "Overwrite existing preset?" ) ) ) + if( !IsOK( wxGetTopLevelParent( this ), _( "Overwrite existing preset?" ) ) ) { resetSelection(); return; @@ -792,7 +793,8 @@ void APPEARANCE_CONTROLS_3D::onViewportChanged( wxCommandEvent& aEvent ) // Save current state to new preset wxString name; - wxTextEntryDialog dlg( this, _( "Viewport name:" ), _( "Save Viewport" ), name ); + wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "Viewport name:" ), + _( "Save Viewport" ), name ); if( dlg.ShowModal() != wxID_OK ) { diff --git a/common/dialogs/panel_color_settings.cpp b/common/dialogs/panel_color_settings.cpp index ee7b755c26..808514339e 100644 --- a/common/dialogs/panel_color_settings.cpp +++ b/common/dialogs/panel_color_settings.cpp @@ -128,7 +128,8 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event ) return; FOOTPRINT_NAME_VALIDATOR themeNameValidator; - wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) ); + wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "New theme name:" ), + _( "Add Color Theme" ) ); dlg.SetTextValidator( themeNameValidator ); if( dlg.ShowModal() != wxID_OK ) @@ -388,4 +389,4 @@ wxString PANEL_COLOR_SETTINGS::GetSettingsDropdownName(COLOR_SETTINGS* aSettings name += wxS( " " ) + _( "(read-only)" ); return name; -} \ No newline at end of file +} diff --git a/common/dialogs/panel_grid_settings.cpp b/common/dialogs/panel_grid_settings.cpp index d4da0b298b..8b708523f5 100644 --- a/common/dialogs/panel_grid_settings.cpp +++ b/common/dialogs/panel_grid_settings.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -229,7 +229,8 @@ bool PANEL_GRID_SETTINGS::TransferDataToWindow() void PANEL_GRID_SETTINGS::OnAddGrid( wxCommandEvent& event ) { GRID newGrid = GRID{ wxEmptyString, "", "" }; - DIALOG_GRID_SETTINGS dlg( this->GetParent(), m_eventSource, m_unitsProvider, newGrid ); + DIALOG_GRID_SETTINGS dlg( wxGetTopLevelParent( this ), m_eventSource, m_unitsProvider, + newGrid ); if( dlg.ShowModal() != wxID_OK ) return; @@ -241,8 +242,11 @@ void PANEL_GRID_SETTINGS::OnAddGrid( wxCommandEvent& event ) { if( newGrid == g ) { - DisplayError( this, wxString::Format( _( "Grid size '%s' already exists." ), - g.UserUnitsMessageText( m_unitsProvider ) ) ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + DisplayError( topLevelParent, + wxString::Format( _( "Grid size '%s' already exists." ), + g.UserUnitsMessageText( m_unitsProvider ) ) ); return; } } @@ -260,7 +264,10 @@ void PANEL_GRID_SETTINGS::OnRemoveGrid( wxCommandEvent& event ) if( gridCfg.grids.size() <= 1 ) { - DisplayError( this, wxString::Format( _( "At least one grid size is required." ) ) ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + DisplayError( topLevelParent, + wxString::Format( _( "At least one grid size is required." ) ) ); return; } diff --git a/common/dialogs/panel_hotkeys_editor.cpp b/common/dialogs/panel_hotkeys_editor.cpp index 355ac96c7e..f463665910 100644 --- a/common/dialogs/panel_hotkeys_editor.cpp +++ b/common/dialogs/panel_hotkeys_editor.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 1992-2023 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -200,7 +200,8 @@ void PANEL_HOTKEYS_EDITOR::ImportHotKeys() { wxString filename = wxFileSelector( _( "Import Hotkeys File:" ), m_frame->GetMruPath(), wxEmptyString, FILEEXT::HotkeyFileExtension, - FILEEXT::HotkeyFileWildcard(), wxFD_OPEN, this ); + FILEEXT::HotkeyFileWildcard(), wxFD_OPEN, + wxGetTopLevelParent( this ) ); if( filename.IsEmpty() ) return; @@ -229,8 +230,9 @@ void PANEL_HOTKEYS_EDITOR::ImportHotKeys() void PANEL_HOTKEYS_EDITOR::dumpHotkeys() { wxString filename = wxFileSelector( wxT( "Hotkeys File" ), m_frame->GetMruPath(), - wxEmptyString, FILEEXT::TextFileExtension, FILEEXT::TextFileWildcard(), - wxFD_SAVE, this ); + wxEmptyString, FILEEXT::TextFileExtension, + FILEEXT::TextFileWildcard(), + wxFD_SAVE, wxGetTopLevelParent( this ) ); if( filename.IsEmpty() ) return; diff --git a/common/dialogs/panel_image_editor.cpp b/common/dialogs/panel_image_editor.cpp index 4cf85db255..6379355d88 100644 --- a/common/dialogs/panel_image_editor.cpp +++ b/common/dialogs/panel_image_editor.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2018 jean-pierre.charras - * Copyright (C) 2011-2023 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2011-2024 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -81,9 +81,10 @@ bool PANEL_IMAGE_EDITOR::CheckValues() if( size_min < MIN_SIZE ) // if the size is too small, the image will be hard to locate { - wxMessageBox( wxString::Format( _( "This scale results in an image which is too small " - "(%.2f mm or %.1f mil)." ), - 25.4 / 300 * size_min, 1000.0 / 300.0 * size_min ) ); + wxMessageDialog( wxGetTopLevelParent( this ), + wxString::Format( _( "This scale results in an image which is too " + "small (%.2f mm or %.1f mil)." ), + 25.4 / 300 * size_min, 1000.0 / 300.0 * size_min ) ); return false; } @@ -92,9 +93,10 @@ bool PANEL_IMAGE_EDITOR::CheckValues() if( size_max > MAX_SIZE ) { // the actual size is 25.4/300 * size_max in mm - if( !IsOK( this, wxString::Format( _( "This scale results in an image which is very large " - "(%.1f mm or %.2f in). Are you sure?" ), - 25.4 / 300 * size_max, size_max / 300.0 ) ) ) + if( !IsOK( wxGetTopLevelParent( this ), + wxString::Format( _( "This scale results in an image which is very large " + "(%.1f mm or %.2f in). Are you sure?" ), + 25.4 / 300 * size_max, size_max / 300.0 ) ) ) { return false; } diff --git a/common/dialogs/panel_setup_netclasses.cpp b/common/dialogs/panel_setup_netclasses.cpp index 5ace68356a..40fe33c90f 100644 --- a/common/dialogs/panel_setup_netclasses.cpp +++ b/common/dialogs/panel_setup_netclasses.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004-2009 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -156,7 +156,8 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA wxGridCellAttr* attr = new wxGridCellAttr; attr->SetRenderer( new GRID_CELL_COLOR_RENDERER( PAGED_DIALOG::GetDialog( this ) ) ); - attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ), m_netclassGrid ) ); + attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ), + m_netclassGrid ) ); m_netclassGrid->SetColAttr( GRID_SCHEMATIC_COLOR, attr ); attr = new wxGridCellAttr; @@ -595,7 +596,9 @@ void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick( wxCommandEvent& event ) } else if( curRow == 0 ) { - DisplayErrorMessage( this, _( "The default net class is required." ) ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + DisplayErrorMessage( topLevelParent, _( "The default net class is required." ) ); return; } diff --git a/common/dialogs/panel_text_variables.cpp b/common/dialogs/panel_text_variables.cpp index a8f6e32bb2..2811650c4c 100644 --- a/common/dialogs/panel_text_variables.cpp +++ b/common/dialogs/panel_text_variables.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -236,9 +236,11 @@ void PANEL_TEXT_VARIABLES::OnUpdateUI( wxUpdateUIEvent& event ) int width = m_TextVars->GetClientRect().GetWidth(); m_TextVars->AutoSizeColumn( TV_NAME_COL ); - m_TextVars->SetColSize( TV_NAME_COL, std::max( 72, m_TextVars->GetColSize( TV_NAME_COL ) ) ); + m_TextVars->SetColSize( TV_NAME_COL, + std::max( 72, m_TextVars->GetColSize( TV_NAME_COL ) ) ); - m_TextVars->SetColSize( TV_VALUE_COL, std::max( 120, width - m_TextVars->GetColSize( TV_NAME_COL ) ) ); + m_TextVars->SetColSize( TV_VALUE_COL, + std::max( 120, width - m_TextVars->GetColSize( TV_NAME_COL ) ) ); m_gridWidthsDirty = false; } @@ -253,7 +255,9 @@ void PANEL_TEXT_VARIABLES::OnUpdateUI( wxUpdateUIEvent& event ) wxString errorMsg = m_errorMsg; m_errorMsg = wxEmptyString; - DisplayErrorMessage( this, errorMsg ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + DisplayErrorMessage( topLevelParent, errorMsg ); m_TextVars->SetFocus(); m_TextVars->MakeCellVisible( m_errorRow, m_errorCol ); diff --git a/common/widgets/wx_html_report_panel.cpp b/common/widgets/wx_html_report_panel.cpp index 25b50ababd..752f28a9ce 100644 --- a/common/widgets/wx_html_report_panel.cpp +++ b/common/widgets/wx_html_report_panel.cpp @@ -386,7 +386,8 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event ) msg.Printf( _( "Cannot write report to file '%s'." ), fn.GetFullPath().GetData() ); - wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR, this ); + wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR, + wxGetTopLevelParent( this ) ); return; } diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index 7f57a78483..8be6bb25fb 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -145,7 +145,8 @@ bool PANEL_EESCHEMA_COLOR_SETTINGS::validateSave( bool aQuiet ) "and they will not be seen on the screen. Are you\n" "sure you want to use these colors?" ); - if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO ) + if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, + wxGetTopLevelParent( this ) ) == wxNO ) return false; break; diff --git a/eeschema/dialogs/panel_setup_buses.cpp b/eeschema/dialogs/panel_setup_buses.cpp index afcab9aa98..968c7343d8 100644 --- a/eeschema/dialogs/panel_setup_buses.cpp +++ b/eeschema/dialogs/panel_setup_buses.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 CERN - * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.txt for contributors. * @author Jon Evans * * This program is free software: you can redistribute it and/or modify it @@ -394,7 +394,9 @@ void PANEL_SETUP_BUSES::OnUpdateUI( wxUpdateUIEvent& event ) wxString errorMsg = m_errorMsg; m_errorMsg = wxEmptyString; - DisplayErrorMessage( this, errorMsg ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + DisplayErrorMessage( topLevelParent, errorMsg ); m_errorGrid->SetFocus(); m_errorGrid->MakeCellVisible( m_errorRow, 0 ); diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index ae9993b414..49f43253c2 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -433,7 +433,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables() else msg = _( "A library table row path cell is empty." ); - wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ), + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog badCellDlg( topLevelParent, msg, _( "Invalid Row Definition" ), wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT ); badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are " "invalid to be removed from the table." ) ); @@ -462,7 +464,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables() m_cur_grid->MakeCellVisible( r, 0 ); m_cur_grid->SetGridCursor( r, 1 ); - wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) ); errdlg.ShowModal(); return false; } @@ -512,7 +516,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables() m_cur_grid->MakeCellVisible( r2, 0 ); m_cur_grid->SetGridCursor( r2, 1 ); - wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) ); errdlg.ShowModal(); return false; @@ -550,7 +556,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables() { msg.Printf( _( "Symbol library '%s' failed to load." ), row.GetNickName() ); - wxMessageDialog errdlg( this, msg + wxS( "\n" ) + ioe.What(), + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog errdlg( topLevelParent, msg + wxS( "\n" ) + ioe.What(), _( "Error Loading Library" ) ); errdlg.ShowModal(); @@ -641,7 +649,8 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) if( !applyToAll ) { // The cancel button adds the library to the table anyway - addDuplicates = OKOrCancelDialog( this, warning, wxString::Format( msg, nickname ), + addDuplicates = OKOrCancelDialog( wxGetTopLevelParent( this ), warning, + wxString::Format( msg, nickname ), detailedMsg, _( "Skip" ), _( "Add Anyway" ), &applyToAll ) == wxID_CANCEL; } @@ -876,7 +885,10 @@ void PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries( wxCommandEvent& event ) if( !legacyLib.Exists() ) { msg.Printf( _( "Library '%s' not found." ), relPath ); - DisplayErrorMessage( this, msg ); + + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + DisplayErrorMessage( topLevelParent, msg ); continue; } @@ -917,7 +929,10 @@ void PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries( wxCommandEvent& event ) else { msg.Printf( _( "Failed to save symbol library file '%s'." ), newLib.GetFullPath() ); - DisplayErrorMessage( this, msg ); + + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + DisplayErrorMessage( topLevelParent, msg ); } } } diff --git a/include/confirm.h b/include/confirm.h index abe483534c..0f8f6303c2 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -181,7 +181,8 @@ KICOMMON_API int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning, const wxString& aMessage, const wxString& aDetailedMessage = wxEmptyString, const wxString& aOKLabel = wxEmptyString, - const wxString& aCancelLabel = wxEmptyString, bool* aApplyToAll = nullptr ); + const wxString& aCancelLabel = wxEmptyString, + bool* aApplyToAll = nullptr ); diff --git a/kicad/import_project.cpp b/kicad/import_project.cpp index 6bddcd5818..a009824081 100644 --- a/kicad/import_project.cpp +++ b/kicad/import_project.cpp @@ -166,4 +166,4 @@ void KICAD_MANAGER_FRAME::OnImportEasyEdaProFiles( wxCommandEvent& event ) { ImportNonKiCadProject( _( "Import EasyEDA Pro Project" ), FILEEXT::EasyEdaProFileWildcard(), { "INPUT" }, { "INPUT" }, SCH_IO_MGR::SCH_EASYEDAPRO, PCB_IO_MGR::EASYEDAPRO ); -} \ No newline at end of file +} diff --git a/kicad/pcm/dialogs/panel_packages_view.cpp b/kicad/pcm/dialogs/panel_packages_view.cpp index 32a0ac92fa..53905ddc78 100644 --- a/kicad/pcm/dialogs/panel_packages_view.cpp +++ b/kicad/pcm/dialogs/panel_packages_view.cpp @@ -106,7 +106,7 @@ PANEL_PACKAGES_VIEW::PANEL_PACKAGES_VIEW( wxWindow* PANEL_PACKAGES_VIEW::~PANEL_PACKAGES_VIEW() { m_splitter1->Disconnect( wxEVT_IDLE, wxIdleEventHandler( PANEL_PACKAGES_VIEW::SetSashOnIdle ), - NULL, this ); + NULL, this ); COMMON_SETTINGS* cfg = Pgm().GetCommonSettings(); cfg->m_PackageManager.sash_pos = m_splitter1->GetSashPosition(); @@ -516,7 +516,8 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event ) if( !ver_it->download_url ) { wxMessageBox( _( "Package download url is not specified" ), - _( "Error downloading package" ), wxICON_INFORMATION | wxOK, this ); + _( "Error downloading package" ), wxICON_INFORMATION | wxOK, + wxGetTopLevelParent( this ) ); return; } @@ -559,7 +560,8 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event ) && wxMessageBox( _( "Integrity of the downloaded package could not be verified, hash " "does not match. Are you sure you want to keep this file?" ), - _( "Keep downloaded file" ), wxICON_EXCLAMATION | wxYES_NO, this ) + _( "Keep downloaded file" ), wxICON_EXCLAMATION | wxYES_NO, + wxGetTopLevelParent( this ) ) == wxNO ) { wxRemoveFile( path ); @@ -610,7 +612,8 @@ void PANEL_PACKAGES_VIEW::OnVersionActionClicked( wxCommandEvent& event ) if( !ver_it->compatible && wxMessageBox( _( "This package version is incompatible with your KiCad version or " "platform. Are you sure you want to install it anyway?" ), - _( "Install package" ), wxICON_EXCLAMATION | wxYES_NO, this ) + _( "Install package" ), wxICON_EXCLAMATION | wxYES_NO, + wxGetTopLevelParent( this ) ) == wxNO ) { return; diff --git a/kicad/project_tree_item.cpp b/kicad/project_tree_item.cpp index 2a6cbf3c54..e73cb3b2f8 100644 --- a/kicad/project_tree_item.cpp +++ b/kicad/project_tree_item.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index cc3b7d25f6..9516128f3e 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1038,7 +1038,7 @@ void PROJECT_TREE_PANE::onRenameFile( wxCommandEvent& event ) wxString buffer = m_TreeProject->GetItemText( curr_item ); wxString msg = wxString::Format( _( "Change filename: '%s'" ), tree_data[0]->GetFileName() ); - wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer ); + wxTextEntryDialog dlg( wxGetTopLevelParent( this ), msg, _( "Change filename" ), buffer ); if( dlg.ShowModal() != wxID_OK ) return; // canceled by user @@ -1535,8 +1535,10 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) if( error == 0 ) { // Directory is already a git repository + wxWindow* topLevelParent = wxGetTopLevelParent( this ); - DisplayInfoMessage( this, _( "The selected directory is already a git project." ) ); + DisplayInfoMessage( topLevelParent, + _( "The selected directory is already a git project." ) ); git_repository_free( repo ); return; } @@ -1552,7 +1554,7 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) if( m_gitLastError != git_error_last()->klass ) { m_gitLastError = git_error_last()->klass; - DisplayErrorMessage( this, _( "Failed to initialize git project." ), + DisplayErrorMessage( m_parent, _( "Failed to initialize git project." ), git_error_last()->message ); } @@ -1565,7 +1567,7 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) } } - DIALOG_GIT_REPOSITORY dlg( this, repo ); + DIALOG_GIT_REPOSITORY dlg( wxGetTopLevelParent( this ), repo ); dlg.SetTitle( _( "Set default remote" ) ); @@ -1620,7 +1622,7 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) if( m_gitLastError != git_error_last()->klass ) { m_gitLastError = git_error_last()->klass; - DisplayErrorMessage( this, _( "Failed to set default remote." ), + DisplayErrorMessage( m_parent, _( "Failed to set default remote." ), git_error_last()->message ); } @@ -1636,7 +1638,9 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) handler.SetPassword( m_TreeProject->GitCommon()->GetPassword() ); handler.SetSSHKey( m_TreeProject->GitCommon()->GetSSHKey() ); - handler.SetProgressReporter( std::make_unique( this, _( "Fetching Remote" ), 1 ) ); + handler.SetProgressReporter( std::make_unique( this, + _( "Fetching Remote" ), + 1 ) ); handler.PerformFetch(); @@ -1673,7 +1677,9 @@ void PROJECT_TREE_PANE::onGitPullProject( wxCommandEvent& aEvent ) handler.SetPassword( m_TreeProject->GitCommon()->GetPassword() ); handler.SetSSHKey( m_TreeProject->GitCommon()->GetSSHKey() ); - handler.SetProgressReporter( std::make_unique( this, _( "Fetching Remote" ), 1 ) ); + handler.SetProgressReporter( std::make_unique( this, + _( "Fetching Remote" ), + 1 ) ); handler.PerformPull(); } @@ -1693,13 +1699,15 @@ void PROJECT_TREE_PANE::onGitPushProject( wxCommandEvent& aEvent ) handler.SetPassword( m_TreeProject->GitCommon()->GetPassword() ); handler.SetSSHKey( m_TreeProject->GitCommon()->GetSSHKey() ); - handler.SetProgressReporter( std::make_unique( this, _( "Fetching Remote" ), 1 ) ); + handler.SetProgressReporter( std::make_unique( this, + _( "Fetching Remote" ), + 1 ) ); if( handler.PerformPush() != PushResult::Success ) { wxString errorMessage = handler.GetErrorString(); - DisplayErrorMessage( this, _( "Failed to push project" ), errorMessage ); + DisplayErrorMessage( m_parent, _( "Failed to push project" ), errorMessage ); } } @@ -1745,13 +1753,13 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent ) if( !repo ) return; - DIALOG_GIT_SWITCH dlg( this, repo ); + DIALOG_GIT_SWITCH dlg( wxGetTopLevelParent( this ), repo ); int retval = dlg.ShowModal(); wxString branchName = dlg.GetBranchName(); if( retval == wxID_ADD ) - git_create_branch( repo, branchName); + git_create_branch( repo, branchName ); else if( retval != wxID_OK ) return; @@ -1761,8 +1769,9 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent ) if( git_reference_lookup( &branchRef, repo, branchName.mb_str() ) != GIT_OK && git_reference_dwim( &branchRef, repo, branchName.mb_str() ) != GIT_OK ) { - wxString errorMessage = wxString::Format( _( "Failed to lookup branch '%s': %s" ), branchName, giterr_last()->message ); - DisplayError( this, errorMessage ); + wxString errorMessage = wxString::Format( _( "Failed to lookup branch '%s': %s" ), + branchName, giterr_last()->message ); + DisplayError( m_parent, errorMessage ); return; } @@ -1774,7 +1783,7 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent ) { wxString errorMessage = wxString::Format( _( "Failed to find branch head for '%s'" ), branchName ); - DisplayError( this, errorMessage ); + DisplayError( m_parent, errorMessage ); git_reference_free( branchRef ); return; } @@ -1785,7 +1794,7 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent ) { wxString errorMessage = wxString::Format( _( "Failed to switch to branch '%s'" ), branchName ); - DisplayError( this, errorMessage ); + DisplayError( m_parent, errorMessage ); git_reference_free( branchRef ); git_object_free( branchObj ); return; @@ -1796,7 +1805,7 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent ) { wxString errorMessage = wxString::Format( _( "Failed to update HEAD reference for branch '%s'" ), branchName ); - DisplayError( this, errorMessage ); + DisplayError( m_parent, errorMessage ); git_reference_free( branchRef ); git_object_free( branchObj ); return; @@ -1813,7 +1822,8 @@ void PROJECT_TREE_PANE::onGitRemoveVCS( wxCommandEvent& aEvent ) git_repository* repo = m_TreeProject->GetGitRepo(); if( !repo - || !IsOK( this, _( "Are you sure you want to remove git tracking from this project?" ) ) ) + || !IsOK( wxGetTopLevelParent( this ), + _( "Are you sure you want to remove git tracking from this project?" ) ) ) { return; } @@ -1830,7 +1840,7 @@ void PROJECT_TREE_PANE::onGitRemoveVCS( wxCommandEvent& aEvent ) if( !RmDirRecursive( fn.GetPath(), &errors ) ) { - DisplayErrorMessage( this, _( "Failed to remove git directory" ), errors ); + DisplayErrorMessage( m_parent, _( "Failed to remove git directory" ), errors ); } // Clear all item states @@ -2129,7 +2139,8 @@ void PROJECT_TREE_PANE::onGitCommit( wxCommandEvent& aEvent ) git_status_list_free( status_list ); // Create a commit dialog - DIALOG_GIT_COMMIT dlg( this, repo, authorName, authorEmail, modifiedFiles ); + DIALOG_GIT_COMMIT dlg( wxGetTopLevelParent( this ), repo, authorName, authorEmail, + modifiedFiles ); auto ret = dlg.ShowModal(); if( ret == wxID_OK ) diff --git a/pagelayout_editor/dialogs/properties_frame.cpp b/pagelayout_editor/dialogs/properties_frame.cpp index 8893ea8495..96a71ce0c8 100644 --- a/pagelayout_editor/dialogs/properties_frame.cpp +++ b/pagelayout_editor/dialogs/properties_frame.cpp @@ -673,7 +673,7 @@ void PROPERTIES_FRAME::onScintillaCharAdded( wxStyledTextEvent &aEvent ) void PROPERTIES_FRAME::onHelp( wxCommandEvent& aEvent ) { // Show the system variables for worksheet text: - HTML_MESSAGE_BOX dlg( this, _( "Predefined Keywords" ) ); + HTML_MESSAGE_BOX dlg( wxGetTopLevelParent( this ), _( "Predefined Keywords" ) ); wxString message; message << _( "Texts can include keywords." ) << "
"; diff --git a/pcb_calculator/calculator_panels/panel_regulator.cpp b/pcb_calculator/calculator_panels/panel_regulator.cpp index 31513855c3..a8d1d1da01 100644 --- a/pcb_calculator/calculator_panels/panel_regulator.cpp +++ b/pcb_calculator/calculator_panels/panel_regulator.cpp @@ -196,7 +196,7 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event ) void PANEL_REGULATOR::OnAddRegulator( wxCommandEvent& event ) { - DIALOG_REGULATOR_FORM dlg( this, wxEmptyString ); + DIALOG_REGULATOR_FORM dlg( wxGetTopLevelParent( this ), wxEmptyString ); if( dlg.ShowModal() != wxID_OK ) return; @@ -230,7 +230,7 @@ void PANEL_REGULATOR::OnEditRegulator( wxCommandEvent& event ) if( item == nullptr ) return; - DIALOG_REGULATOR_FORM dlg( this, name ); + DIALOG_REGULATOR_FORM dlg( wxGetTopLevelParent( this ), name ); dlg.CopyRegulatorDataToDialog( item ); diff --git a/pcb_calculator/dialogs/dialog_regulator_form.cpp b/pcb_calculator/dialogs/dialog_regulator_form.cpp index ee11ee7455..ec7c924dcf 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form.cpp +++ b/pcb_calculator/dialogs/dialog_regulator_form.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2011 jean-pierre.charras - * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,7 +28,7 @@ extern double DoubleFromString( const wxString& TextValue ); -DIALOG_REGULATOR_FORM::DIALOG_REGULATOR_FORM( PANEL_REGULATOR* parent, const wxString& aRegName ) : +DIALOG_REGULATOR_FORM::DIALOG_REGULATOR_FORM( wxWindow* parent, const wxString& aRegName ) : DIALOG_REGULATOR_FORM_BASE( parent ) { m_textCtrlName->SetValue( aRegName ); diff --git a/pcb_calculator/dialogs/dialog_regulator_form.h b/pcb_calculator/dialogs/dialog_regulator_form.h index 3e1c7a296f..fb6a0fa2ea 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form.h +++ b/pcb_calculator/dialogs/dialog_regulator_form.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2011 jean-pierre.charras - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,7 +39,7 @@ class REGULATOR_DATA; class DIALOG_REGULATOR_FORM : public DIALOG_REGULATOR_FORM_BASE { public: - DIALOG_REGULATOR_FORM( PANEL_REGULATOR* parent, const wxString& aRegName ); + DIALOG_REGULATOR_FORM( wxWindow* parent, const wxString& aRegName ); ~DIALOG_REGULATOR_FORM(); diff --git a/pcbnew/dialogs/panel_fp_editor_defaults.cpp b/pcbnew/dialogs/panel_fp_editor_defaults.cpp index eb09a3fff8..765f0c32cf 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults.cpp +++ b/pcbnew/dialogs/panel_fp_editor_defaults.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -473,7 +473,8 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow() if( errorsMsg.IsEmpty() ) return true; - KIDIALOG dlg( this, errorsMsg, KIDIALOG::KD_ERROR, _( "Parameter error" ) ); + KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR, + _( "Parameter error" ) ); dlg.ShowModal(); return false; diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index 85fc2ab1aa..eb8f392cf2 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -541,7 +541,9 @@ bool PANEL_FP_LIB_TABLE::verifyTables() else msg = _( "A library table row path cell is empty." ); - wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ), + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog badCellDlg( topLevelParent, msg, _( "Invalid Row Definition" ), wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT ); badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are " "invalid to be removed from the table." ) ); @@ -570,7 +572,9 @@ bool PANEL_FP_LIB_TABLE::verifyTables() m_cur_grid->MakeCellVisible( r, 0 ); m_cur_grid->SetGridCursor( r, 1 ); - wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) ); errdlg.ShowModal(); return false; } @@ -616,7 +620,9 @@ bool PANEL_FP_LIB_TABLE::verifyTables() m_cur_grid->MakeCellVisible( r2, 0 ); m_cur_grid->SetGridCursor( r2, 1 ); - wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) ); errdlg.ShowModal(); return false; } @@ -833,7 +839,7 @@ void PANEL_FP_LIB_TABLE::onMigrateLibraries( wxCommandEvent& event ) if( !legacyLib.Exists() ) { msg.Printf( _( "Library '%s' not found." ), relPath ); - DisplayErrorMessage( this, msg ); + DisplayErrorMessage( wxGetTopLevelParent( this ), msg ); continue; } @@ -875,7 +881,7 @@ void PANEL_FP_LIB_TABLE::onMigrateLibraries( wxCommandEvent& event ) else { msg.Printf( _( "Failed to save footprint library file '%s'." ), newLib.GetFullPath() ); - DisplayErrorMessage( this, msg ); + DisplayErrorMessage( wxGetTopLevelParent( this ), msg ); } } } @@ -1026,7 +1032,8 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) if( !applyToAll ) { // The cancel button adds the library to the table anyway - addDuplicates = OKOrCancelDialog( this, warning, wxString::Format( msg, nickname ), + addDuplicates = OKOrCancelDialog( wxGetTopLevelParent( this ), warning, + wxString::Format( msg, nickname ), detailedMsg, _( "Skip" ), _( "Add Anyway" ), &applyToAll ) == wxID_CANCEL; } @@ -1155,6 +1162,7 @@ void PANEL_FP_LIB_TABLE::populateEnvironReadOnlyTable() // the current project. unique.insert( PROJECT_VAR_NAME ); unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() ); + // This special environment variable is used to locate 3d shapes unique.insert( KICAD7_3DMODEL_DIR ); diff --git a/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp b/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp index d8f73f48f1..d588ac010f 100644 --- a/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp +++ b/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp @@ -245,7 +245,7 @@ void PANEL_PCBNEW_ACTION_PLUGINS::OnShowErrorsButtonClick( wxCommandEvent& event // Now display the filtered trace in our dialog // (a simple wxMessageBox is really not suitable for long messages) - DIALOG_FOOTPRINT_WIZARD_LOG logWindow( this ); + DIALOG_FOOTPRINT_WIZARD_LOG logWindow( wxGetTopLevelParent( this ) ); logWindow.m_Message->SetValue( trace ); logWindow.ShowModal(); } diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index 973e5d9b25..e804af7245 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2009 Isaac Marino Bavaresco, isaacbavaresco@yahoo.com.br * Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -431,8 +431,9 @@ void PANEL_SETUP_LAYERS::DenyChangeCheckBox( wxCommandEvent& event ) if( source == copper ) { - DisplayError( this, _( "Use the Physical Stackup page to change the number of " - "copper layers." ) ); + DisplayError( wxGetTopLevelParent( this ), + _( "Use the Physical Stackup page to change the number of " + "copper layers." ) ); copper->SetValue( true ); return; @@ -464,19 +465,21 @@ bool PANEL_SETUP_LAYERS::TransferDataFromWindow() for( unsigned int ii = 0; ii < notremovableLayers.size(); ii++ ) msg << m_pcb->GetLayerName( notremovableLayers[ii] ) << wxT( "\n" ); - if( !IsOK( this, wxString::Format( _( "Footprints have some items on removed layers:\n" - "%s\n" - "These items will be no longer accessible\n" - "Do you wish to continue?" ), msg ) ) ) + if( !IsOK( wxGetTopLevelParent( this ), + wxString::Format( _( "Footprints have some items on removed layers:\n" + "%s\n" + "These items will be no longer accessible\n" + "Do you wish to continue?" ), msg ) ) ) { return false; } } if( !removedLayers.empty() - && !IsOK( this, _( "Items have been found on removed layers. This operation will " - "delete all items from removed layers and cannot be undone.\n" - "Do you wish to continue?" ) ) ) + && !IsOK( wxGetTopLevelParent( this ), + _( "Items have been found on removed layers. This operation will " + "delete all items from removed layers and cannot be undone.\n" + "Do you wish to continue?" ) ) ) { return false; } @@ -799,7 +802,9 @@ bool PANEL_SETUP_LAYERS::CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aIm newNumLayers, currNumLayers ); - wxMessageDialog dlg( this, msg, _( "Inner Layers To Be Deleted" ), + wxWindow* topLevelParent = wxGetTopLevelParent( this ); + + wxMessageDialog dlg( topLevelParent, msg, _( "Inner Layers To Be Deleted" ), wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT ); if( wxID_NO == dlg.ShowModal() ) diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 369fc2b095..2943faeeed 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -102,7 +102,7 @@ void PANEL_SETUP_RULES::onCharHook( wxKeyEvent& aEvent ) { if( m_originalText != m_textEditor->GetText() ) { - if( IsOK( this, _( "Cancel Changes?" ) ) ) + if( IsOK( wxGetTopLevelParent( this ), _( "Cancel Changes?" ) ) ) { m_textEditor->SetText( m_originalText ); m_textEditor->SelectAll(); diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp index ea2bca61f2..624feb5857 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp +++ b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp @@ -310,7 +310,8 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow() if( errorsMsg.IsEmpty() ) return true; - KIDIALOG dlg( this, errorsMsg, KIDIALOG::KD_ERROR, _( "Parameter error" ) ); + KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR, + _( "Parameter error" ) ); dlg.ShowModal(); return false; diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 1bf0bbea58..47ae10d554 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -2635,7 +2635,8 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) if( m_lastSelectedUserPreset ) name = m_lastSelectedUserPreset->name; - wxTextEntryDialog dlg( this, _( "Layer preset name:" ), _( "Save Layer Preset" ), name ); + wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "Layer preset name:" ), + _( "Save Layer Preset" ), name ); if( dlg.ShowModal() != wxID_OK ) { @@ -2662,14 +2663,14 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) else if( preset->readOnly ) { wxMessageBox( _( "Default presets cannot be modified.\nPlease use a different name." ), - _( "Error" ), wxOK | wxICON_ERROR, this ); + _( "Error" ), wxOK | wxICON_ERROR, wxGetTopLevelParent( this ) ); resetSelection(); return; } else { // Ask the user if they want to overwrite the existing preset - if( !IsOK( this, _( "Overwrite existing preset?" ) ) ) + if( !IsOK( wxGetTopLevelParent( this ), _( "Overwrite existing preset?" ) ) ) { resetSelection(); return; @@ -2862,7 +2863,8 @@ void APPEARANCE_CONTROLS::onViewportChanged( wxCommandEvent& aEvent ) // Save current state to new preset wxString name; - wxTextEntryDialog dlg( this, _( "Viewport name:" ), _( "Save Viewport" ), name ); + wxTextEntryDialog dlg( wxGetTopLevelParent( this ), + _( "Viewport name:" ), _( "Save Viewport" ), name ); if( dlg.ShowModal() != wxID_OK ) {