Skip to content

Commit

Permalink
Merge pull request #1362 from KeyWorksRW/art_provider
Browse files Browse the repository at this point in the history
Fix crash in Book Pages that specify an unrecognized ART id
  • Loading branch information
Randalphwa authored Jan 1, 2024
2 parents 38f068c + 091ba37 commit 9af3a36
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 4 deletions.
45 changes: 45 additions & 0 deletions src/art_src/unknown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions src/generate/gen_book_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////
// Purpose: Common Book utilities
// Author: Ralph Walden
// Copyright: Copyright (c) 2020-2023 KeyWorks Software (Ralph Walden)
// Copyright: Copyright (c) 2020-2024 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////

Expand All @@ -11,6 +11,7 @@
#include "gen_common.h" // Common component functions
#include "node.h" // Node class
#include "project_handler.h" // ProjectHandler class
#include "ui_images.h" // Generated images header

#include "gen_book_utils.h"

Expand Down Expand Up @@ -63,7 +64,12 @@ void AddBookImageList(Node* node_book, wxObject* widget)
{
if (child_node->hasValue(prop_bitmap))
{
bundle_list.push_back(child_node->as_wxBitmapBundle(prop_bitmap));
auto bundle = child_node->as_wxBitmapBundle(prop_bitmap);
if (!bundle.IsOk())
{
bundle = wxue_img::bundle_unknown_svg(24, 24);
}
bundle_list.push_back(bundle);
}

if (node_book->isGen(gen_wxTreebook))
Expand Down
11 changes: 9 additions & 2 deletions src/generate/gen_toolbook.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////
// Purpose: wxToolbook generator
// Author: Ralph Walden
// Copyright: Copyright (c) 2020-2022 KeyWorks Software (Ralph Walden)
// Copyright: Copyright (c) 2020-2024 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////

Expand All @@ -12,6 +12,7 @@
#include "gen_xrc_utils.h" // Common XRC generating functions
#include "node.h" // Node class
#include "pugixml.hpp" // xml read/write/create/process
#include "ui_images.h" // Generated images header
#include "utils.h" // Utility functions that work with properties

#include "gen_toolbook.h"
Expand All @@ -26,7 +27,13 @@ wxObject* ToolbookGenerator::CreateMockup(Node* node, wxObject* parent)
{
if (node->getChild(idx_child)->hasValue(prop_bitmap))
{
bundle_list.push_back(node->getChild(idx_child)->as_wxBitmapBundle(prop_bitmap));
auto bundle = node->getChild(idx_child)->as_wxBitmapBundle(prop_bitmap);
if (!bundle.IsOk())
{
bundle = wxue_img::bundle_unknown_svg(24, 24);
}

bundle_list.push_back(bundle);
}
}
auto book = wxStaticCast(widget, wxBookCtrlBase);
Expand Down
72 changes: 72 additions & 0 deletions src/wxui/ui_images.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,73 @@ namespace wxue_img
101,202,245,216,127,0,90,154,164,62,50,221,138,13,0,0,0,0,73,69,78,68,174,66,96,130
};

const unsigned char unknown_svg[2108] {
120,218,165,151,219,110,156,201,13,132,243,40,63,38,55,9,240,79,187,217,236,3,91,43,249,38,200,101,158,33,208,90,99,175,
176,178,37,72,138,19,249,233,243,85,143,236,181,129,93,32,64,12,24,26,81,125,32,139,85,197,158,203,167,207,31,222,94,
222,156,222,63,109,183,55,87,7,125,168,135,183,151,183,159,126,125,122,119,253,112,186,120,56,61,62,61,156,222,61,223,
126,62,109,79,247,55,183,15,252,191,120,126,121,56,93,29,126,92,227,55,135,237,91,228,243,195,63,255,115,117,200,219,
197,102,121,36,211,207,31,255,250,242,245,175,89,63,242,143,127,252,114,117,176,18,169,212,156,237,15,142,120,189,242,
120,255,120,251,225,246,211,213,161,215,100,133,195,156,117,195,146,79,253,123,221,67,89,223,85,17,135,55,111,47,223,
168,206,183,151,31,126,59,240,238,250,231,211,221,213,225,239,63,159,62,157,126,184,233,195,227,253,191,30,62,222,223,
80,240,221,245,203,233,241,124,224,250,200,178,231,199,235,79,79,239,239,31,63,94,29,214,199,187,235,231,211,95,142,94,
75,234,54,125,63,90,68,154,62,254,10,164,15,215,207,191,108,79,207,47,119,156,244,254,246,238,238,226,207,148,119,51,
79,63,233,151,227,253,195,245,187,219,231,151,11,206,228,248,127,108,62,115,202,99,86,219,61,44,205,40,213,182,191,109,
62,90,42,62,195,119,31,53,229,86,154,173,88,179,58,235,238,141,149,94,103,172,221,205,35,19,171,45,153,229,233,218,61,
71,154,51,207,70,212,210,40,173,181,173,230,72,214,75,47,196,60,21,176,46,91,53,79,179,142,30,196,34,181,50,217,91,11,
249,68,12,246,54,176,30,85,123,139,165,240,217,198,238,189,37,47,163,118,246,142,20,101,229,61,56,175,245,172,188,171,
149,20,149,207,84,227,201,114,140,65,54,147,88,214,238,160,193,51,154,255,110,213,95,54,161,209,191,198,173,165,74,130,
99,213,243,45,154,107,234,35,242,36,22,41,207,50,124,47,84,219,61,130,156,114,75,217,187,237,37,68,147,22,109,165,84,
83,203,61,234,94,72,190,115,74,89,201,159,15,44,141,79,189,213,246,125,12,128,134,91,25,107,247,183,104,233,36,180,174,
49,75,173,183,182,23,114,44,181,215,202,205,57,69,183,70,54,150,211,8,155,109,229,93,83,245,90,251,94,132,126,54,10,15,
78,241,222,201,38,207,228,54,188,108,130,96,88,51,150,209,144,62,41,114,81,0,101,180,26,58,178,167,128,230,99,197,0,22,
40,139,205,148,75,128,67,64,65,14,36,63,49,48,79,53,17,52,18,177,201,58,24,90,70,233,80,69,224,123,225,56,216,67,190,
220,59,56,163,54,159,132,0,123,76,40,161,123,45,89,244,66,121,109,82,113,117,178,238,72,45,123,9,98,228,31,222,55,231,
195,236,48,155,43,130,218,221,67,155,57,40,247,174,35,225,99,171,150,219,38,30,117,23,92,224,10,189,148,11,161,209,77,
231,57,109,4,16,127,221,108,109,68,161,22,163,185,22,228,216,39,196,204,153,149,185,167,18,29,108,60,136,153,85,197,168,
174,100,183,87,210,91,155,16,156,229,9,132,99,44,130,103,218,50,206,177,225,57,22,193,123,29,94,207,187,185,122,245,25,
161,148,50,109,174,123,234,24,8,169,170,152,89,190,230,211,11,130,83,12,148,155,50,167,127,13,30,104,55,96,120,105,46,
188,145,30,165,113,119,83,243,123,41,11,179,220,230,52,98,25,4,66,164,237,8,101,134,157,239,6,202,25,83,209,72,3,178,
206,173,122,147,228,38,249,208,243,57,123,227,196,82,83,180,169,204,97,17,118,176,172,162,102,221,216,98,44,33,12,152,
38,33,80,183,65,128,37,24,100,97,220,157,105,123,113,41,139,13,157,109,107,51,188,29,106,132,23,120,212,192,124,197,90,
29,21,189,22,148,189,132,32,181,1,17,137,255,22,59,235,210,122,14,251,97,229,55,173,114,34,237,32,157,223,83,245,151,
237,213,177,113,75,204,179,200,173,255,71,231,252,233,233,249,241,254,215,211,241,223,183,55,207,191,92,72,110,8,174,
45,63,253,184,32,46,211,105,164,64,0,76,188,226,221,118,12,117,191,77,140,90,246,214,138,109,199,146,6,75,198,126,68,
216,81,2,65,224,83,19,207,34,2,66,102,62,55,40,7,147,240,119,217,236,168,115,51,213,137,177,236,78,3,172,245,13,109,102,
208,41,251,234,82,29,91,81,255,219,14,77,6,118,188,33,156,70,75,118,92,8,222,208,135,35,18,207,181,236,8,24,213,48,200,
142,93,172,103,11,63,61,231,190,29,57,179,99,5,147,67,122,180,81,201,181,192,175,62,148,199,172,97,50,203,143,27,164,
108,248,66,223,143,40,16,119,110,133,74,169,106,230,86,119,42,182,168,190,9,121,172,144,194,73,44,160,196,38,63,156,45,
83,20,7,56,213,197,134,161,49,26,92,171,68,146,97,27,125,26,20,170,201,54,144,93,43,190,145,176,69,238,190,224,129,139,
26,2,120,1,199,179,8,179,175,2,12,88,152,90,92,15,33,32,32,190,74,189,134,101,41,132,157,80,114,40,52,155,193,109,62,
64,139,193,34,181,165,78,38,214,17,205,53,224,32,164,60,3,195,58,138,204,17,174,125,206,191,182,147,228,100,90,173,237,
165,168,25,86,59,68,35,128,245,215,221,52,175,240,227,13,169,135,176,150,193,34,101,53,29,60,185,198,48,72,171,66,127,
46,231,171,234,7,210,103,138,209,15,22,35,20,89,58,120,169,56,38,162,88,80,23,119,202,202,13,185,91,89,128,97,120,12,
73,81,36,227,27,43,221,234,99,69,74,159,34,29,110,55,60,42,100,96,100,208,87,154,3,227,208,36,233,217,56,55,7,14,119,
86,208,201,92,135,56,152,147,60,14,255,4,101,115,239,171,21,163,58,221,151,7,57,243,2,54,228,129,25,155,26,18,93,132,
193,180,81,33,124,33,25,16,214,88,55,220,149,26,116,65,16,8,112,222,52,229,25,186,216,11,127,208,28,161,225,33,99,114,
198,122,31,140,180,35,115,25,164,58,180,236,168,24,164,144,46,162,176,157,100,81,88,61,55,141,252,99,135,176,180,61,47,
114,51,167,232,153,227,208,234,16,64,13,102,85,221,215,48,195,93,142,152,24,45,112,54,9,223,21,226,110,42,101,210,129,
47,18,160,143,164,87,201,34,118,85,156,197,162,194,26,148,68,231,152,246,214,150,76,248,208,101,93,228,181,232,96,178,
81,108,139,217,130,31,42,25,138,47,85,244,0,212,181,1,222,72,68,189,64,163,21,160,45,77,17,80,161,215,25,86,128,43,20,
104,252,246,229,59,139,250,63,252,169,57,181,248,171,63,49,230,73,55,3,154,236,28,135,239,178,167,65,187,152,73,98,191,
247,16,74,178,23,89,145,152,6,198,117,163,147,45,172,174,72,180,192,105,232,7,208,118,101,79,243,121,92,72,188,84,60,
208,7,178,138,213,117,188,17,136,232,66,160,148,77,244,231,189,40,68,6,109,134,144,112,2,255,30,122,7,206,37,32,51,220,
141,222,180,193,68,85,211,121,239,233,29,10,151,121,9,232,118,222,43,26,14,16,168,243,188,59,218,122,199,156,113,85,21,
101,153,19,68,238,188,75,207,246,202,236,44,125,153,19,175,49,186,138,32,120,63,32,88,241,213,85,38,19,16,142,67,67,166,
16,245,198,18,150,235,117,36,146,53,189,61,89,147,131,1,162,170,112,80,158,121,71,73,214,100,105,93,150,22,190,159,77,
99,22,84,67,229,148,182,78,150,55,202,151,207,118,207,21,174,97,189,38,0,47,63,137,88,15,195,62,23,127,225,18,142,193,
223,114,89,118,77,29,168,192,20,97,133,88,164,7,87,22,238,208,39,143,69,87,180,67,101,232,81,118,86,207,62,132,59,176,
96,44,191,208,171,24,140,208,146,231,66,0,164,0,140,233,194,55,8,217,59,111,143,129,43,77,216,206,183,8,93,202,227,4,
230,82,60,63,52,173,144,39,238,84,118,9,131,47,1,219,194,167,212,115,98,240,99,153,232,170,204,151,137,50,201,116,49,
203,125,250,57,87,30,74,43,2,247,75,215,54,4,41,128,193,87,156,199,140,64,138,249,207,239,89,88,50,22,179,210,147,186,
27,195,110,13,207,145,3,215,196,202,199,104,178,41,61,17,27,118,33,121,186,28,9,222,177,0,68,229,63,60,74,146,126,84,
77,15,189,41,68,197,166,161,35,178,78,134,72,21,55,141,55,57,186,166,43,99,217,75,119,61,160,229,89,149,143,187,172,144,
153,91,150,96,67,79,121,148,93,187,252,92,14,202,147,7,40,73,66,229,133,230,22,185,234,231,244,53,35,42,123,25,192,16,
34,231,177,80,26,46,111,148,252,234,106,31,190,220,203,192,61,97,122,141,229,248,38,99,37,123,243,51,237,49,34,6,72,223,
215,247,207,22,107,147,234,41,52,205,199,40,58,88,38,88,165,62,82,42,203,94,148,131,78,201,121,53,72,147,161,143,197,
11,86,106,65,213,132,144,114,240,243,215,136,233,45,160,198,49,116,125,91,51,68,93,166,14,40,58,190,55,165,245,104,122,
195,215,250,55,250,114,255,167,255,2,175,110,95,41
};

const unsigned char wxButton_png[500] {
137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,22,0,0,0,22,8,6,0,0,0,196,180,108,59,0,0,0,9,112,72,89,115,0,0,11,
19,0,0,11,19,1,0,154,156,24,0,0,1,166,73,68,65,84,56,203,237,148,63,72,91,113,16,199,63,63,243,30,13,1,33,1,229,97,213,
Expand Down Expand Up @@ -1529,6 +1596,11 @@ namespace wxue_img
return wxBitmapBundle::FromBitmap(wxBitmap(get_image(unknown_png, 1699)));
}

wxBitmapBundle bundle_unknown_svg(int width, int height)
{
return get_bundle_svg(unknown_svg, 2108, 4067, wxSize(width, height));
}

wxBitmapBundle bundle_wxButton_png()
{
return wxBitmapBundle::FromBitmap(wxBitmap(get_image(wxButton_png, 500)));
Expand Down
2 changes: 2 additions & 0 deletions src/wxui/ui_images.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace wxue_img
wxBitmapBundle bundle_toolspacer_png(); // toolspacer.png
wxBitmapBundle bundle_undo_svg(int width, int height);
wxBitmapBundle bundle_unknown_png(); // unknown.png
wxBitmapBundle bundle_unknown_svg(int width, int height);
wxBitmapBundle bundle_wxButton_png(); // wxButton.png
wxBitmapBundle bundle_wxCheckBox_png(); // wxCheckBox.png
wxBitmapBundle bundle_wxCheckListBox_png(); // wxCheckListBox.png
Expand Down Expand Up @@ -175,6 +176,7 @@ namespace wxue_img
extern const unsigned char toolspacer_png[459];
extern const unsigned char undo_svg[882];
extern const unsigned char unknown_png[1699];
extern const unsigned char unknown_svg[2108];
extern const unsigned char wxButton_png[500];
extern const unsigned char wxCheckBox_png[202];
extern const unsigned char wxCheckListBox_png[498];
Expand Down
3 changes: 3 additions & 0 deletions src/wxui/wxUiEditor.wxui
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
<node
class="embedded_image"
bitmap="Embed;unknown.png" />
<node
class="embedded_image"
bitmap="SVG;unknown.svg;[16,16]" />
<node
class="embedded_image"
bitmap="Embed;wxButton.png" />
Expand Down

0 comments on commit 9af3a36

Please # to comment.