Skip to content

Commit

Permalink
Merge pull request #1555 from KeyWorksRW/xrc_view_cwd
Browse files Browse the repository at this point in the history
Improve chance that XRC preview will find the artwork.
  • Loading branch information
Randalphwa authored Dec 24, 2024
2 parents 41d4104 + 58d753a commit 7bcffe8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/internal/xrcpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ bool XrcPreview::Create(wxWindow* parent, wxWindowID id, const wxString& title,
/////////////////// Non-generated Copyright/License Info ////////////////////
// Purpose: Test XRC
// Author: Ralph Walden
// Copyright: Copyright (c) 2022 KeyWorks Software (Ralph Walden)
// Copyright: Copyright (c) 2022-2024 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -339,6 +339,9 @@ void XrcPreview::OnPreview(wxCommandEvent& WXUNUSED(event))
return;
}

tt_cwd cwd(true);
wxSetWorkingDirectory(Project.ArtDirectory().make_wxString());

wxDialog dlg;
if (xrc_resource->LoadDialog(&dlg, this, dlg_name))
{
Expand Down Expand Up @@ -399,6 +402,9 @@ void XrcPreview::OnInit(wxInitDialogEvent& event)
m_scintilla->MarkerDefine(node_marker, wxSTC_MARK_BOOKMARK, wxNullColour, *wxGREEN);

event.Skip();

wxCommandEvent dummy;
OnGenerate(dummy);
}

void XrcPreview::OnImport(wxCommandEvent& WXUNUSED(event))
Expand Down
6 changes: 6 additions & 0 deletions src/previews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ void Preview(Node* form_node)
return;
}

tt_cwd cwd(true);
wxSetWorkingDirectory(Project.ArtDirectory().make_wxString());

XrcCompare dlg_compare;
if (!dlg_compare.DoCreate(wxGetMainFrame(), form_node))
{
Expand Down Expand Up @@ -256,6 +259,9 @@ void PreviewXrc(Node* form_node)
return;
}

tt_cwd cwd(true);
wxSetWorkingDirectory(Project.ArtDirectory().make_wxString());

switch (form_node->getGenName())
{
case gen_wxDialog:
Expand Down

0 comments on commit 7bcffe8

Please # to comment.