Commit graph

50 commits

Author SHA1 Message Date
Andres Fernandez de Prado
33dff96a20 This commit contains changes required for MuseScore to compile under MSVC with no warnings.
This commit contains changes required for MuseScore to compile under MSVC with no warnings.

MuseScore is being compiled with the /W4 setting (warning level 4), which is similar to -wall -wextra on clang. This generates lots of warnings on MSVC, mainly for non-standard constructs and for constructs which might be bugs or might lead to bugs.

Most warnings are in the following categories:
- Name hiding: a variable hides a variable with the same name on a larger scope (or a field, or a function parameter). This can easily lead to bugs, and it is a best practice to avoid hiding variable names (see recommendation ES.12 in the C++ Core Guidelines by Stroustrop & Sutter (http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-reuse : ES.12: Do not reuse names in nested scopes)
- Narrowing conversion: a numeric conversion results in loss of significant digits (for example, double -> float). The general recommendation is to use a cast to indicate this is designed behaviour.
- Unreachable code: in several instances, there is unreachable code. The unreachable code is commented out.
- (Potentially) uninitialized local variable. Just initialized the vars.
- foreach(,) -> for(:): this does not generate a warning per-se (only a few of these generate warnings due to name hiding), but changed in keeping with "MuseScore Coding Rules" (https://musescore.org/en/handbook/musescore-coding-rules#Loops), which tells explicitly "Use C++11's "for" instead of Qt's "foreach":" ... "If you happen to be fixing some code and see a "foreach", please change that loop into a "for"."

Most changes are in the categories indicated above. The next listing shows detailed changes for files which are *not* of the aforementioned types.

- all.h: Disable warning C4127 (conditional expression is constant - generated in Qt header file qvector.h)
- awl/aslider.h: unreachable code.
- awl/knob.cpp: name hiding
- awl/mslider.cpp: name hiding
- awl/slider.cpp: name hiding
- bww2mxml/parser.cpp: name hiding
- effects/compressor/compressor.cpp: narrowing conversion
- effects/zita1/zitagui.cpp: name hiding
- fluid/fluid.cpp: foreach replacement. Name hiding.
- fluid/mod.cpp: name hiding.
- fluid/sfont.cpp: foreach replacement. Name hiding. Initialize vars.
- fluid/voice.cpp: Name hiding.
- libmscore/accidental.cpp: Name hiding.
- libmscore/ambitus.cpp: Initialize vars.
- libmscore/barline.cpp: Name hiding. Unreachable code.
- libmscore/beam.cpp: Name hiding.
- libmscore/chordrest.cpp: Unreachable code.
- libmscore/scorefile.cpp: Name hiding.
- manual/genManual.cpp: Name hiding. foreach replacement.
- midi/midifile.cpp: Name hiding. Unreachable code.
- omr/importpdf.cpp: Name hiding. foreach replacement.
- omr/omr.cpp: Name hiding. foreach replacement.
- omr/omrpage.cpp: Name hiding. foreach replacement.
- omr/omrview.cpp: Name hiding. foreach replacement.
- synthesizer/event.cpp: Unreachable code.
- zerberus\channel.cpp: Narrowing conversion.
- zerberus\instrument.cpp: Name hiding.
- zerberus\sfz.cpp: Name hiding.
- zerberus\voice.h: Suppress warning C4201: "nonstandard extension used: nameless struct/union"
- zerberus\zerberus.cpp: Name hiding. Unreferenced parameter.
- zerberus\zerberusgui.cpp: Name hiding.
2018-08-03 09:15:42 +02:00
Andres Fernandez de Prado
3acc363498 Solved all compilation errors on MSVC
This commit contains changes required for MuseScore to compile under MSVC with no errors.

There are several general categories of problems that resulted in errors with the compilation. Main issues:
- Variable Length Arrays (VLA). This is a non-standard extension to C++, supported by clang toolchains, but not by MSVC. The initial workaround is to use std::vector<> instead of VLAs, eventually (if needed) with the original variable pointing to the beginning of the allocated array. More efficient alternatives are possible if profiling shows any code using VLAs to be timing-critical.
- Floating-point constants not suffixed with "f" are doubles by default; in some instances, this leads to narrowing conversion errors (in other instances, just warnings).
- MSVC does not support "or"/"and"/"not" in lieu of "||"/"&&"/"!". Changed unconditionally to use standard C++ symbols.
- MSVC does not support the "__builtin_unreachable()" compiler hint. A similar, albeit not exactly equal, alternative is "__assume(0)", which is MSVC-specific.
- MSVC does not support ranges in case statements. Replaced with list of cases instead of range (non-conditionally)

Detailed changes, with per-file comments:

- all.h: opt-in to deprecated features, include <io.h> and <process.h> instead of POSIX <unistd.h>, undefine "STRING_NONE" and "small", which Microsoft defines as macros, which result in compilation errors.
- effects/compressor/zita.cpp: eliminated narrowing conversion error by appending "f" to float constants.
- fluid/voice.cpp: appended "f" to float constants to eliminate narrowing conversion errors/warnings
- libmscore/beam.cpp: conditionally replaced VLA
- libmscore/edit.cpp: conditionally replaced VLA
- libmscore/element.cpp: appended "f" to float constant
- libmscore/fret.cpp: changed or -> ||
- libmscore/layout.cpp: conditionally replaced VLA
- libmscore/mscore.cpp: conditionally replaced "__builtin_unreachable()" with "__assume(0)" for MSVC
- libmscore/scorefile.coo: use correct char representation conversion for MSVC
- libmscore/stringdata.cpp: conditionally replaced VLA
- libmscore/system.cpp: conditionally replaced VLA
- libmscroe/text.cpp: replaced range in case statement.
- manual/genManual.cpp: use getopt() replacement.
- midi/midifile.cpp: conditionally replaced VLA. This does not use the default replacement.
- mscore/bb.cpp: replaced range in case statement.
- mscore/capella.cpp: conditionally replaced VLA. Changed and -> &&
- mscore/driver:cpp: preclude errors due to macro redefinitions.
- mscore/editstyle.cpp: conditionally replaced "__builtin_unreachable()" with "__assume(0)" for MSVC
- mscore/importgtp-gp6.cpp: conditionally replaced VLA.
- mscore/instrwidget.cpp: conditionally replaced VLA.
- mscore/jackaudio.cpp: conditionally replaced VLA. Preclude errors due to macro redefinitions.
- mscore/jackweakapi.cpp: Preclude errors due to macro redefinitions. Replacement for __atribute__((constructor)) through static object construction for MSVC. Force use of LoadLibraryA instead of LoadLibrary.
- mscore/mididriver.h: Changed not -> !
- mscore/musescore.cpp: Changed not -> !. Conditionally replaced VLA.
- mscore/resourceManager.cpp: conditionally replaced VLA.
- mscore/timeline.cpp: conditionally replaced VLA.
- omr/omrpage.cpp: conditionally replaced VLA.
- synthesizer/msynthesizer.cpp: replaced UNIX sleep(1) method with MSVC Sleep(1000) (equivalent, but in ms instead of seconds)
- synthesizer/msynthsizer.h: appended "f" to float constant
- thirdparty/poppler/config.h: set defines for MSVC to preclude the use of inexistent libraries.
- thirdparty/poppler/poppler/poppler-config.h: set defines for MSVC to preclude the use of inexistent libraries. Eliminated #defines for fmin and fmax which where causing problems.
- thirdparty/poppler/poppler/PSOutputDev.cc: added #include <algorithm> for  std::min() and std::max(). Note this is required per-C++ standard.
- thirdparty/portmidi/pm_win/pmwinmm.c: undefined UNICODE to use char-based library functions.
- thirdparty/qzip/qzip.cpp: changed or -> ||
- thirdparty/rtf2html/rtf_keyword.h: file format changed from Apple to UNIX, as MSVC does not supported the former.

(NOT error related, just improvement on previous commit; manual/getopt/README.md: added link to source article)
2018-08-03 09:15:42 +02:00
Andres Fernandez de Prado
188386ba2e This commit contains all the changes to the CMake build system required to generate a valid Visual Studio 2017 solution and projects for MuseScore.
In detail, changes are as follows:
- Changed .gitignore to ignore VS-specific files and directories.
- VS uses a global settings file for the CMake build process: CMakeSettings.json. This is a text file, which is conceptually equivalent to the Makefile used to invoke CMake through Make. This file might need to be changed on an individual user basis, if dependencies are not installed in default paths.
- New cmake macros to copy files in build\CopyFilesMacros.cmake. The code is from https://cmake.org/pipermail/cmake/2009-March/027892.html
- Pre-compiled headers: Visual Studio requires to create pre-compiled headers per-project (a general per-solution PCH file, although possible, is extremely problematic and not recommended). Therefore, the  new macro vstudio_pch in CreatePrecompiledHeader.cmake was created to add the pre-compiled header creation step to an existing target (similar to what is done for XCode). The existing macro precompiled_header was modified to set the values for a group of variables. As part of this, the empty file all.cpp was added to the root of the source tree, as VS requires a source file to create pre-compiled headers (the header file alone can not be compiled).
- all.h is not copied to binary dir for MSVC, as I could determine no need to do this. Because of this, and the differences in PCH handling, the pseudo-targets mops1 and mops2 are not created for MSVC.
- Revised all steps conditional on toolchain, and added MSVC paths as needed. In many instances, the MSVC path is the same as the MINGW path, but not always.
- The manual (genManual) target used the getopt() functionality defined in POSIX libraries, which is not available on Windows. An LGPL'd port of getopt() for Windows was added in manual\getopt. The original source is in GitHub: nanoporetech/getopt-win32, based on a CodeProject article: https://www.codeproject.com/KB/cpp/getopt4win.aspx?msg=3987371. The corresponding CMakeLists.txt file was modified to include this files when compiling with MSVC.
- Changes in CMakeLists.txt files to create valid MSVC targets. The changes, always conditional on the MSVC toolchain, consist of:
     x Setting target properties for MSVC
     x Using all.h in source dir
     x Adding pre-compiled headers to target
     x Removing dependency from mops1 and mops2

Notes:
- The INSTALL target has NOT BEEN UPDATED for MSVC.
2018-08-03 09:15:42 +02:00
lasconic
d069e9e4a3 fix #270690: default zita reverb settings too boomy 2018-03-25 23:20:26 +02:00
luz.paz
443be63167 Misc. typos
Found via `codespell -i 3 -w --skip="./thirdparty,./share/locale,./fonts" -I ../musescore-whitelist.txt`
Whitelist:
```
clas
nd
ot
pres
strack
tage
te
```
2018-02-13 12:06:05 -05:00
Joachim Schmitz
bc18929579 Fix #268554: Improved string for "Makeup gain" knob 2018-01-17 19:50:56 +01:00
vinayak
38db24a243 fix #104771: Dragging mouse up/down moves Zita1 controls the wrong way. 2017-01-02 23:04:29 +05:30
werner
863c9ac1fd slur cleanups 2016-07-04 13:21:52 +02:00
ws
cc3c9c7d5c fix #104981: synthesizer: zita1 reverb: Eq2 not working 2016-04-19 23:46:18 +02:00
Nicolas Froment
6526bb976b Merge pull request #2483 from Jojo-Schmitz/about
Simplify texts in various dialogs, for translators' benefit
2016-04-18 20:07:52 +02:00
ws
e9c7791ba9 fix zita process() loop 2016-03-29 13:42:06 +04:00
Joachim Schmitz
356a7c85dd Simplify texts in various dialogs, for translators' benefit
by eliminating html stuff from the to be translated texts.
Move urls out of translations, which is also good for security
reasons, to protect us from bogus and malicous translations.
Some formatting changes and getting some error messages to stderr.
Updating copyright to 2016 in the due course.
2016-03-25 09:06:56 +01:00
lasconic
a355fb6173 fix small typo in compressor UI 2016-03-09 09:59:03 +04:00
lasconic
cd6dd3edd7 fix a couple of warnings on Mac OSX 2016-02-15 12:33:54 +04:00
lasconic
273e4bfc8f fix multiple typos 2015-09-22 16:40:54 +02:00
Joachim Schmitz
3b0f7a883d fix typos 2015-09-14 16:18:35 +02:00
ws
5349e4f537 fix compressor gui 2015-09-14 15:52:26 +02:00
ws
04f209db0e add spinbox to compressor values 2015-09-14 15:09:39 +02:00
ws
fe29c614de make synthcontrol and mixer persistent 2015-09-08 17:14:02 +02:00
ws
b622c8fda5 fix compilation on windowns 2015-09-08 15:53:37 +02:00
ws
8f5fa69542 add compressor effect 2015-09-08 15:39:30 +02:00
lasconic
426d8fdf27 fix #47811: Crash when showing Synthesizer panel in fullscreen 2015-03-03 23:02:44 +01:00
lasconic
45b2695531 fix non fatal build errrors on mac osx 2015-02-19 23:17:14 +01:00
AntonioBL
3528de04da fix compilation on Mac OS X 2015-02-02 18:48:50 +01:00
ws
b3c8465eed more cmake cleanups 2015-01-27 15:23:20 +01:00
ws
1960bbbff7 use AUTOMOC in cmake files 2015-01-27 15:23:20 +01:00
Joachim Schmitz
4eb005d501 some (pre-)translation fixes 2015-01-18 08:50:16 +01:00
ws
f22515c0ef reimplement effect gui without qml 2015-01-07 13:47:19 +01:00
ws
b16957bf17 replace QQuickView in effects with QQuickWidget 2014-12-17 14:17:21 +01:00
Joachim Schmitz
48f3ea412a initialize variables 2014-06-10 09:27:48 +02:00
Joachim Schmitz
ebf7981933 disable unused private members 2014-06-10 09:27:45 +02:00
Joachim Schmitz
6f3a7d1957 whitespace cleanup 2014-05-30 13:37:44 +02:00
lasconic
25aa51c900 fix #24289: typo in effects/zita1/mixsect.png 2014-02-10 14:11:02 +01:00
ws
2abfd73485 enable mtest plugins 2013-07-11 12:25:25 +02:00
ws
5f1cae610b fix rotary direction in zita gui; add mouse wheel events 2013-07-11 10:38:30 +02:00
lasconic
7b14868a48 add missing files for effects 2013-07-10 23:34:28 +02:00
ws
a685cb9e6d rollback effects gui; fixes for mstyle 2013-07-10 21:59:00 +02:00
ws
5c781cff6a change effect gui implementation 2013-07-10 15:29:58 +02:00
ws
8f028e8157 fix colornotes plugin example 2013-07-10 10:33:05 +02:00
ws
4e6aaa1ba4 for debugging remove iostream from bww2mxml 2013-07-09 16:56:38 +02:00
ws
f448d29ab4 move to qml2 2013-05-16 17:10:33 +02:00
ws
9ebabcc2e5 add namespace Ms 2013-05-13 19:43:59 +02:00
ws
2deb49be5a add store/recall global synthesizer settings; connect tuning settings 2013-04-19 17:15:30 +02:00
ws
1c43f086a4 fix regression: export audio 2013-04-04 12:12:10 +02:00
ws
b83a8ac58d reorder synthesizer; enable zita1 by default; more cleanups 2013-04-03 18:11:38 +02:00
ws
a8a9241699 fixes for synthesizer 2013-04-03 17:18:25 +02:00
ws
f866d7903a move driverFactory() into separate file 2013-04-03 15:45:12 +02:00
ws
53cb0ec925 some regression fixes 2013-04-03 15:02:03 +02:00
ws
bc46048cd3 update synthesizer implementation 2013-04-03 12:50:21 +02:00
ws
220db94494 reorganize synthesizer; add zita1 reverb 2013-04-03 12:50:21 +02:00