diff --git a/.gitmodules b/.gitmodules index 58637a746..dabc567d7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,4 +10,4 @@ url = http://git.sv.nongnu.org/r/freetype/freetype2.git [submodule "extlib/libdxfrw"] path = extlib/libdxfrw - url = https://github.com/whitequark/libdxfrw.git + url = https://github.com/solvespace/libdxfrw.git diff --git a/.travis.yml b/.travis.yml index 5daea078f..5e831b192 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,23 +5,41 @@ os: sudo: required dist: trusty install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; sudo apt-get install -q -y cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev libgtkmm-2.4-dev libpangomm-1.4-dev libgl1-mesa-dev libglu-dev libglew-dev libfreetype6-dev dpkg-dev; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew upgrade cmake libpng; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/install-debian.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/install-macos.sh; fi script: - - mkdir cbuild - - cd cbuild - - cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DCMAKE_BUILD_TYPE=Debug .. - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd ..; dpkg-buildpackage -b -us -uc; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/build-debian.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/build-macos.sh; fi deploy: + # Releases to solvespace/solvespace + - provider: releases + api_key: + secure: dDlkIawHcODlW9B/20/cQCtzeoocvs0hKuNngRKXKqzXLWTRq33oq/B7+39tAixWbmv6exTpijiKrRNFiSCW5Z4iwHLwaRD4XJznxw63e/Hus/dxg2Tvqx7XFpkCz8mT1Z+gZQE5YxAngeZPpI/sZbZtF1UO3yH5eLeeokZ15p26ZskQUPoYuzrTgTzYL3XfpG3F+20rNBawH1ycsCTVD/08/n31d2m3CrKAsbW7er92ek6w4fzKr7NW8WeXjrPJETVpw5fQg1Od3pRGW8dPQaJcvKQEogMp8Mm0ETYd0qigg89/giBz7QwOgmAWQ4dH+DfZH4Ojl//127QztBolMvyDMQBykWrtJoGcij05sT6K2IJr2FHeUBO12MAEdjiVvhQj3DtTzjPiZAHHDBSLWxLKWWhlhHE4pq7g1MQhqXkaAHI2BLNzwLmaowbMT0bECf9yfz6xx18h6XPQFX44oOktraobVALFlyHqeKa8zdcUt22LF6uAL1m5dxL0tny3eXCIPE4UH/RZgua/cHV9G3cUvKQa/QnFSLRhvWVSbGB+7YsHouBJcsUOOW1gmd5442XuC7mpppccRldh+GSxUk6TBJRAx7TeQ0ybDUaoco9MUqp2twv3KreR2+8Q12PDaAhfQVNEGdF3wTm1sShImjCN4VN3eSLlBEbve1QRQXM= + skip_cleanup: true + file_glob: true + file: + - ../*.deb + on: + repo: solvespace/solvespace + tags: true + condition: "$TRAVIS_OS_NAME == linux" + - provider: releases + api_key: + secure: dDlkIawHcODlW9B/20/cQCtzeoocvs0hKuNngRKXKqzXLWTRq33oq/B7+39tAixWbmv6exTpijiKrRNFiSCW5Z4iwHLwaRD4XJznxw63e/Hus/dxg2Tvqx7XFpkCz8mT1Z+gZQE5YxAngeZPpI/sZbZtF1UO3yH5eLeeokZ15p26ZskQUPoYuzrTgTzYL3XfpG3F+20rNBawH1ycsCTVD/08/n31d2m3CrKAsbW7er92ek6w4fzKr7NW8WeXjrPJETVpw5fQg1Od3pRGW8dPQaJcvKQEogMp8Mm0ETYd0qigg89/giBz7QwOgmAWQ4dH+DfZH4Ojl//127QztBolMvyDMQBykWrtJoGcij05sT6K2IJr2FHeUBO12MAEdjiVvhQj3DtTzjPiZAHHDBSLWxLKWWhlhHE4pq7g1MQhqXkaAHI2BLNzwLmaowbMT0bECf9yfz6xx18h6XPQFX44oOktraobVALFlyHqeKa8zdcUt22LF6uAL1m5dxL0tny3eXCIPE4UH/RZgua/cHV9G3cUvKQa/QnFSLRhvWVSbGB+7YsHouBJcsUOOW1gmd5442XuC7mpppccRldh+GSxUk6TBJRAx7TeQ0ybDUaoco9MUqp2twv3KreR2+8Q12PDaAhfQVNEGdF3wTm1sShImjCN4VN3eSLlBEbve1QRQXM= + skip_cleanup: true + file: build/solvespace.dmg + on: + repo: solvespace/solvespace + tags: true + condition: "$TRAVIS_OS_NAME == osx" + # Releases to whitequark/solvespace (to be removed) - provider: releases api_key: secure: DA3tW0My37vbi2t3dZ061281Xm8KSIkeLdFZsQISrut0g1kkbWuBTPxAfvE3B6OE8p47wAclE/wxA1+obMTVkY0oYpd5u+JelYNHxU/oL8Ww0xdUANwKNJ1JD2EZP8nSz7JSvxuGILC6AFPoTjawsG97SXwiTyp7z0PA6nvzraE= skip_cleanup: true file_glob: true file: - - ../solvespace_*.deb - - ../solvespace-dbg_*.deb + - ../*.deb on: repo: whitequark/solvespace tags: true @@ -30,7 +48,7 @@ deploy: api_key: secure: DA3tW0My37vbi2t3dZ061281Xm8KSIkeLdFZsQISrut0g1kkbWuBTPxAfvE3B6OE8p47wAclE/wxA1+obMTVkY0oYpd5u+JelYNHxU/oL8Ww0xdUANwKNJ1JD2EZP8nSz7JSvxuGILC6AFPoTjawsG97SXwiTyp7z0PA6nvzraE= skip_cleanup: true - file: /Users/travis/build/whitequark/solvespace/cbuild/solvespace.dmg + file: build/solvespace.dmg on: repo: whitequark/solvespace tags: true diff --git a/.travis/build-debian.sh b/.travis/build-debian.sh new file mode 100755 index 000000000..9d0a4c05b --- /dev/null +++ b/.travis/build-debian.sh @@ -0,0 +1,6 @@ +#!/bin/sh -xe + +if echo $TRAVIS_TAG | grep ^release-; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=Debug; fi + +export BUILD_TYPE +dpkg-buildpackage -b -us -uc diff --git a/.travis/build-macos.sh b/.travis/build-macos.sh new file mode 100755 index 000000000..291097300 --- /dev/null +++ b/.travis/build-macos.sh @@ -0,0 +1,8 @@ +#!/bin/sh -xe + +if echo $TRAVIS_TAG | grep ^release-; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=Debug; fi + +mkdir build +cd build +cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. +make diff --git a/.travis/install-debian.sh b/.travis/install-debian.sh new file mode 100755 index 000000000..146190f0a --- /dev/null +++ b/.travis/install-debian.sh @@ -0,0 +1,7 @@ +#!/bin/sh -xe + +sudo apt-get update -qq +sudo apt-get install -q -y \ + cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev \ + libgtkmm-2.4-dev libpangomm-1.4-dev libgl1-mesa-dev libglu-dev libglew-dev \ + libfreetype6-dev dpkg-dev diff --git a/.travis/install-macos.sh b/.travis/install-macos.sh new file mode 100755 index 000000000..6fb5a4f72 --- /dev/null +++ b/.travis/install-macos.sh @@ -0,0 +1,4 @@ +#!/bin/sh -xe + +brew update +brew upgrade cmake libpng diff --git a/README.md b/README.md index 5f0132e1e..0e1d2d222 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ SolveSpace ========== -This repository contains the official repository of [SolveSpace][]. +[![Build status](https://ci.appveyor.com/api/projects/status/ny959umcretcmfts/branch/master?svg=true)](https://ci.appveyor.com/project/whitequark/solvespace/branch/master) +[![Build status](https://travis-ci.org/solvespace/solvespace.svg?branch=master)](https://travis-ci.org/solvespace/solvespace) + +This repository contains the source code of [SolveSpace][], a parametric +2d/3d CAD. [solvespace]: http://solvespace.com @@ -13,7 +17,7 @@ Installation Binary packages for Mac OS X and Debian derivatives are available via [GitHub releases][rel]. -[rel]: https://github.com/whitequark/solvespace/releases +[rel]: https://github.com/solvespace/solvespace/releases ### Other systems @@ -38,8 +42,8 @@ Before building, check out the necessary submodules: After that, build SolveSpace as following: - mkdir cbuild - cd cbuild + mkdir build + cd build cmake .. make sudo make install @@ -60,19 +64,19 @@ Before building, check out the necessary submodules: After that, build 32-bit SolveSpace as following: - mkdir cbuild - cd cbuild + mkdir build + cd build cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake .. make solvespace Or, build 64-bit SolveSpace as following: - mkdir cbuild - cd cbuild + mkdir build + cd build cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake .. make solvespace -The application is built as `cbuild/src/solvespace.exe`. +The application is built as `build/src/solvespace.exe`. Space Navigator support will not be available. @@ -92,12 +96,12 @@ Before building, check out the necessary submodules: After that, build SolveSpace as following: - mkdir cbuild - cd cbuild + mkdir build + cd build cmake .. make -The app bundle is built in `cbuild/src/solvespace.app`. +The app bundle is built in `build/src/solvespace.app`. [homebrew]: http://brew.sh/ diff --git a/appveyor.yml b/appveyor.yml index ed7f58b1c..4103a80ab 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,18 +1,33 @@ version: 2.1.{build} +clone_depth: 1 before_build: - git submodule update --init - - mkdir cbuild - - cd cbuild - - cmake -G"Visual Studio 12" -T v120_xp .. -build: - project: C:\projects\solvespace\cbuild\src\solvespace.vcxproj - verbosity: minimal + - mkdir build + - cd build + - set tag=x%APPVEYOR_REPO_TAG_NAME% + - if %tag:~,9% == xrelease- (set BUILD_TYPE=RelWithDebInfo) else (set BUILD_TYPE=Debug) + - cmake -G"Visual Studio 12" -T v120_xp -DCMAKE_BUILD_TYPE=%BUILD_TYPE% .. +build_script: + - msbuild "C:\projects\solvespace\build\src\solvespace.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" artifacts: - - path: cbuild\src\Debug\solvespace.exe + - path: build\src\Debug\solvespace.exe name: solvespace.exe - - path: cbuild\src\Debug\solvespace.pdb + - path: build\src\Debug\solvespace.pdb + name: solvespace.pdb + - path: build\src\RelWithDebInfo\solvespace.exe + name: solvespace.exe + - path: build\src\RelWithDebInfo\solvespace.pdb name: solvespace.pdb deploy: + # Releases to solvespace/solvespace + - provider: GitHub + auth_token: + secure: P9/pf2nM+jlWKe7pCjMp41HycBNP/+5AsmE/TETrDUoBOa/9WFHelqdVFrbRn9IC + description: "" + artifact: solvespace.exe + on: + appveyor_repo_tag: true + # Releases to whitequark/solvespace (to be removed) - provider: GitHub auth_token: secure: Flqxu1cz6PyxVT1wzTP4bSrQOY8wFrO7pJxYxvjEkLqIUU4dsDQrs2rac/A9deet diff --git a/debian/rules b/debian/rules index eee3b3988..084b447bf 100755 --- a/debian/rules +++ b/debian/rules @@ -15,7 +15,8 @@ include /usr/share/dpkg/default.mk # This is example for Cmake (See http://bugs.debian.org/641051 ) override_dh_auto_configure: dh_auto_configure -- \ - -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) + -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) \ + -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) # create a -dbg package override_dh_strip: diff --git a/src/draw.cpp b/src/draw.cpp index b4fdbc1db..79feb1663 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -299,7 +299,7 @@ void GraphicsWindow::GroupSelection(void) { gs.constraint[(gs.constraints)++] = s->constraint; Constraint *c = SK.GetConstraint(s->constraint); if(c->IsStylable()) gs.stylables++; - if(c->type == Constraint::COMMENT) gs.comments++; + if(c->HasLabel()) gs.constraintLabels++; } } } @@ -434,7 +434,7 @@ Vector GraphicsWindow::UnProjectPoint3(Vector p) { double w = 1 + p.z * SS.CameraTangent() * scale; p.x *= w / scale; p.y *= w / scale; - + Vector orig = offset.ScaledBy(-1); orig = orig.Plus(projRight.ScaledBy(p.x)).Plus( projUp. ScaledBy(p.y).Plus( diff --git a/src/drawconstraint.cpp b/src/drawconstraint.cpp index 6ccaa1039..32deb981a 100644 --- a/src/drawconstraint.cpp +++ b/src/drawconstraint.cpp @@ -1229,3 +1229,21 @@ bool Constraint::IsStylable() { return false; } +bool Constraint::HasLabel() { + switch(type) { + case COMMENT: + case PT_PT_DISTANCE: + case PT_PLANE_DISTANCE: + case PT_LINE_DISTANCE: + case PT_FACE_DISTANCE: + case PROJ_PT_DISTANCE: + case LENGTH_RATIO: + case LENGTH_DIFFERENCE: + case DIAMETER: + case ANGLE: + return true; + + default: + return false; + } +} diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index bca2ab50b..c9f2be8c4 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -175,39 +175,31 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = { #undef TC #undef TR -bool SolveSpace::MakeAcceleratorLabel(int accel, char *out) { - if(!accel) { - out[0] = '\0'; - return false; - } - - const char *ctrl = accel & GraphicsWindow::CTRL_MASK ? "Ctrl+" : ""; - const char *shift = accel & GraphicsWindow::SHIFT_MASK ? "Shift+" : ""; - - char buf[8]; - buf[0] = (char)(accel & 0xff); - buf[1] = '\0'; +std::string SolveSpace::MakeAcceleratorLabel(int accel) { + if(!accel) return ""; + std::string label; + if(accel & GraphicsWindow::CTRL_MASK) { + label += "Ctrl+"; + } + if(accel & GraphicsWindow::SHIFT_MASK) { + label += "Shift+"; + } if(accel >= GraphicsWindow::FUNCTION_KEY_BASE + 1 && accel <= GraphicsWindow::FUNCTION_KEY_BASE + 12) { - sprintf(buf, "F%d", accel - GraphicsWindow::FUNCTION_KEY_BASE); - } - - const char *key = buf; - - switch(accel) { - case '\t': key = "Tab"; break; - case ' ': key = "Space"; break; - - case GraphicsWindow::ESCAPE_KEY: key = "Esc"; break; - case GraphicsWindow::DELETE_KEY: key = "Del"; break; + label += ssprintf("F%d", accel - GraphicsWindow::FUNCTION_KEY_BASE); + } else if(accel == '\t') { + label += "Tab"; + } else if(accel == ' ') { + label += "Space"; + } else if(accel == GraphicsWindow::ESCAPE_KEY) { + label += "Esc"; + } else if(accel == GraphicsWindow::DELETE_KEY) { + label += "Del"; + } else { + label += (char)(accel & 0xff); } - - if(key[0] < '!' || key[0] > '~') oops(); - if(key[0] >= 'a' && key[0] <= 'z') oops(); - - sprintf(out, "%s%s%s", ctrl, shift, key); - return true; + return label; } void GraphicsWindow::Init(void) { @@ -896,9 +888,10 @@ void GraphicsWindow::MenuEdit(int id) { break; } SS.GW.GroupSelection(); - if(SS.GW.gs.points == 0 && SS.GW.gs.comments == 0) { - Error("Can't snap these items to grid; select points or " - "text comments. To snap a line, select its endpoints."); + if(SS.GW.gs.points == 0 && SS.GW.gs.constraintLabels == 0) { + Error("Can't snap these items to grid; select points, " + "text comments, or constraints with a label. " + "To snap a line, select its endpoints."); break; } SS.UndoRemember(); @@ -916,8 +909,6 @@ void GraphicsWindow::MenuEdit(int id) { SS.MarkGroupDirty(ep->group); } else if(s->constraint.v) { Constraint *c = SK.GetConstraint(s->constraint); - if(c->type != Constraint::COMMENT) continue; - c->disp.offset = SS.GW.SnapToGrid(c->disp.offset); } } diff --git a/src/gtk/gtkmain.cpp b/src/gtk/gtkmain.cpp index ab54d561a..e26a5417a 100644 --- a/src/gtk/gtkmain.cpp +++ b/src/gtk/gtkmain.cpp @@ -387,7 +387,13 @@ class EditorOverlay : public Gtk::Fixed { font_desc.set_absolute_size(font_height * Pango::SCALE); #ifdef HAVE_GTK3 - _entry.override_font(font_desc); + /* For some reason override_font doesn't take screen DPI into + account on GTK3 when working with font descriptors specified + in absolute sizes; modify_font does on GTK2. */ + Pango::FontDescription override_font_desc(font_desc); + double dpi = get_screen()->get_resolution(); + override_font_desc.set_size(font_height * 72.0 / dpi * Pango::SCALE); + _entry.override_font(override_font_desc); #else _entry.modify_font(font_desc); #endif @@ -399,12 +405,13 @@ class EditorOverlay : public Gtk::Fixed { Glib::RefPtr layout = Pango::Layout::create(get_pango_context()); layout->set_font_description(font_desc); layout->set_text(val + " "); /* avoid scrolling */ - int width = std::max(minWidthChars * font_metrics.get_approximate_char_width(), - layout->get_logical_extents().get_width()) / Pango::SCALE; + int width = layout->get_logical_extents().get_width(); #ifdef HAVE_GTK3 Gtk::Border border = _entry.get_style_context()->get_padding(); move(_entry, x - border.get_left(), y - border.get_top()); + _entry.set_width_chars(minWidthChars); + _entry.set_size_request(width / Pango::SCALE, -1); #else /* We need _gtk_entry_effective_inner_border, but it's not in the public API, so emulate its logic. */ @@ -413,10 +420,13 @@ class EditorOverlay : public Gtk::Fixed { &style_border, NULL); if(style_border) border = *style_border; move(_entry, x - border.left, y - border.top); + /* This is what set_width_chars does. */ + int minWidth = minWidthChars * std::max(font_metrics.get_approximate_digit_width(), + font_metrics.get_approximate_char_width()); + _entry.set_size_request(std::max(width, minWidth) / Pango::SCALE, -1); #endif _entry.set_text(val); - _entry.set_size_request(width, -1); if(!_entry.is_visible()) { _entry.show(); _entry.grab_focus(); diff --git a/src/mouse.cpp b/src/mouse.cpp index 79fc0fde0..3c213d54e 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -571,7 +571,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) { CMNU_OTHER_ANGLE); } } - if(gs.comments > 0 || gs.points > 0) { + if(gs.constraintLabels > 0 || gs.points > 0) { AddContextMenuItem("Snap to Grid", CMNU_SNAP_TO_GRID); } @@ -779,6 +779,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) { SS.TW.GoToScreen(TextWindow::SCREEN_GROUP_INFO); SS.TW.shown.group = hg; SS.ScheduleShowTW(); + ForceTextWindowShown(); break; } @@ -799,12 +800,14 @@ void GraphicsWindow::MouseRightUp(double x, double y) { SS.TW.GoToScreen(TextWindow::SCREEN_STYLE_INFO); SS.TW.shown.style = hs; SS.ScheduleShowTW(); + ForceTextWindowShown(); break; } case CMNU_NEW_CUSTOM_STYLE: { uint32_t v = Style::CreateCustomStyle(); Style::AssignSelectionToStyle(v); + ForceTextWindowShown(); break; } diff --git a/src/sketch.h b/src/sketch.h index 4738e3fa5..65e082148 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -682,6 +682,7 @@ class Constraint : public ConstraintBase { void Draw(void); void GetEdges(SEdgeList *sel); bool IsStylable(); + bool HasLabel(); void LineDrawOrGetDistance(Vector a, Vector b); bool IsVisible() const; diff --git a/src/solvespace.h b/src/solvespace.h index 8786e3620..910cdfc9e 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -388,7 +388,7 @@ void MakeMatrix(double *mat, double a11, double a12, double a13, double a14, double a21, double a22, double a23, double a24, double a31, double a32, double a33, double a34, double a41, double a42, double a43, double a44); -bool MakeAcceleratorLabel(int accel, char *out); +std::string MakeAcceleratorLabel(int accel); bool FilenameHasExtension(const std::string &str, const char *ext); void Message(const char *str, ...); void Error(const char *str, ...); diff --git a/src/toolbar.cpp b/src/toolbar.cpp index 0860dd58c..84a36ece4 100644 --- a/src/toolbar.cpp +++ b/src/toolbar.cpp @@ -206,20 +206,19 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my, // Do this last so that nothing can draw over it. if(toolTip.show) { ssglInitializeBitmapFont(); - if(strlen(toolTip.str) >= 200) oops(); - std::string str { toolTip.str }; + std::string str = toolTip.str; for(i = 0; SS.GW.menu[i].level >= 0; i++) { if(toolbarTooltipped == SS.GW.menu[i].id) { - char accelbuf[40]; - if(MakeAcceleratorLabel(SS.GW.menu[i].accel, accelbuf)) { - str += ssprintf(" (%s)", accelbuf); + std::string accel = MakeAcceleratorLabel(SS.GW.menu[i].accel); + if(!accel.empty()) { + str += ssprintf(" (%s)", accel.c_str()); } break; } } - int tw = str.length() * SS.TW.CHAR_WIDTH + 10, + int tw = str.length() * (SS.TW.CHAR_WIDTH - 1) + 10, th = SS.TW.LINE_HEIGHT + 2; double ox = toolbarMouseX + 3, oy = toolbarMouseY + 3; diff --git a/src/ui.h b/src/ui.h index 1c5e07f20..15f64dd44 100644 --- a/src/ui.h +++ b/src/ui.h @@ -649,7 +649,7 @@ class GraphicsWindow { int vectors; int constraints; int stylables; - int comments; + int constraintLabels; int withEndpoints; int n; } gs; diff --git a/src/win32/w32main.cpp b/src/win32/w32main.cpp index e206dad71..dc5025310 100644 --- a/src/win32/w32main.cpp +++ b/src/win32/w32main.cpp @@ -1208,11 +1208,9 @@ HMENU CreateGraphicsWindowMenus(void) for(i = 0; SS.GW.menu[i].level >= 0; i++) { std::string label; if(SS.GW.menu[i].label) { - char accelbuf[40]; - const char *sep = - MakeAcceleratorLabel(SS.GW.menu[i].accel, accelbuf) ? - "\t" : ""; - label = ssprintf("%s%s%s", SS.GW.menu[i].label, sep, accelbuf); + std::string accel = MakeAcceleratorLabel(SS.GW.menu[i].accel); + const char *sep = accel.empty() ? "" : "\t"; + label = ssprintf("%s%s%s", SS.GW.menu[i].label, sep, accel.c_str()); } if(SS.GW.menu[i].level == 0) {