Permalink
Browse files

Don't call wxString constructor when creating wxMenuItem, fix #468

  • Loading branch information...
jhasse committed Sep 12, 2018
1 parent f7349f3 commit 49568a4ae82708a1a74d4fed064df120d3230a2f
Showing with 1 addition and 1 deletion.
  1. +1 −1 output/plugins/common/xml/menutoolbar.cppcode
@@ -133,7 +133,7 @@ Written by
<templates class="wxMenuItem">
<template name="declaration">wxMenuItem* $name;</template>
<template name="construction">
$name = new wxMenuItem( #parent $name, $id, wxString( $label ) #ifnotnull $shortcut @{ + wxT('\t') + $shortcut @}, $help, $kind );
$name = new wxMenuItem(#parent $name, $id, $label #ifnotnull $shortcut @{+wxT('\t')+$shortcut @}, $help, $kind);
</template>
<template name="settings">
#ifnotequal $kind "wxITEM_RADIO"

1 comment on commit 49568a4

@ga2k

This comment has been minimized.

Show comment
Hide comment
@ga2k

ga2k Sep 12, 2018

Woops. Maybe it was needed after all. I made the change to menubar.cppcode and generated a test program. When using a menu Label and Shortcut, compilation fails (MSWIN) with the following...

1>d:\dev\wxphonebook\framebase.cpp(165): error C2110: '+': cannot add two pointers
1>d:\dev\wxphonebook\framebase.cpp(165): error C2248: 'wxString::wxString': cannot access private member declared in class 'wxString'
1>d:\wxwidgets-3.1.1\include\wx\string.h(303): note: see declaration of 'wxString::wxString'
1>d:\wxwidgets-3.1.1\include\wx\gdicmn.h(38): note: see declaration of 'wxString'

When the new generated code

menuFileExit = new wxMenuItem( menuFile, wxID_EXIT, wxT("Exit") + wxT('\t') + wxT("Alt-F4"), wxEmptyString, wxITEM_NORMAL );

is replaced with (the old way)

menuFileExit = new wxMenuItem( menuFile, wxID_EXIT, wxString(wxT("Exit")) + wxT('\t') + wxT("Alt-F4"), wxEmptyString, wxITEM_NORMAL );

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Maybe this needs to be rolled back? Sorry.

ga2k commented on 49568a4 Sep 12, 2018

Woops. Maybe it was needed after all. I made the change to menubar.cppcode and generated a test program. When using a menu Label and Shortcut, compilation fails (MSWIN) with the following...

1>d:\dev\wxphonebook\framebase.cpp(165): error C2110: '+': cannot add two pointers
1>d:\dev\wxphonebook\framebase.cpp(165): error C2248: 'wxString::wxString': cannot access private member declared in class 'wxString'
1>d:\wxwidgets-3.1.1\include\wx\string.h(303): note: see declaration of 'wxString::wxString'
1>d:\wxwidgets-3.1.1\include\wx\gdicmn.h(38): note: see declaration of 'wxString'

When the new generated code

menuFileExit = new wxMenuItem( menuFile, wxID_EXIT, wxT("Exit") + wxT('\t') + wxT("Alt-F4"), wxEmptyString, wxITEM_NORMAL );

is replaced with (the old way)

menuFileExit = new wxMenuItem( menuFile, wxID_EXIT, wxString(wxT("Exit")) + wxT('\t') + wxT("Alt-F4"), wxEmptyString, wxITEM_NORMAL );

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Maybe this needs to be rolled back? Sorry.

Please sign in to comment.