diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-11-16 12:30:51 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-11-16 12:30:51 +0800 |
commit | af657df8a4accb3758138769e3cc5b86530b57d5 (patch) | |
tree | 9563dc2e9b1ea36dc4d50be52c2e1d717f1fb8d6 | |
parent | c12df3744f04716e88e905888beeaaa4f331d687 (diff) | |
download | QMidiPlayer-af657df8a4accb3758138769e3cc5b86530b57d5.tar.xz |
Even more fixes for Microsoft(R) Windows(R) operating system.
Device initalization file dialog doesn't work correctly on Windows.
Make hiding console an option on Windows.
For some dumb reason preset selection dialog refuses to work if no
soundfont is selected.
-rw-r--r-- | core/qmpmidioutrtmidi.cpp | 11 | ||||
-rw-r--r-- | qmidiplayer-desktop/main.cpp | 11 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpdevpropdialog.cpp | 2 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmppresetselect.cpp | 1 |
4 files changed, 13 insertions, 12 deletions
diff --git a/core/qmpmidioutrtmidi.cpp b/core/qmpmidioutrtmidi.cpp index 6dc9ca6..eeda04b 100644 --- a/core/qmpmidioutrtmidi.cpp +++ b/core/qmpmidioutrtmidi.cpp @@ -26,14 +26,16 @@ qmpDeviceInitializer* qmpDeviceInitializer::parse(const char* path) { qmpDeviceInitializer *ret=new qmpDeviceInitializer(); ret->initseq.eventList.clear(); - FILE* f=fopen(path, "r"); - if(!f)return nullptr; bool st_inmapping=false; char buf[1024]; int ln=0; int cmsb=-1,clsb=-1; +#define err(e) {delete ret;return fprintf(stderr,"line %d: %s",ln,e),nullptr;} + FILE* f=fopen(path,"r"); + if(!f)err("file not found") + //writing such a bad parser makes me want my money for //the credits from "compiler principles" back... auto h2d=[](char c)->char{return 'F'>=c&&c>='A'?c-'A'+10:'9'>=c&&c>='0'?c-'0':-1;}; @@ -45,7 +47,6 @@ qmpDeviceInitializer* qmpDeviceInitializer::parse(const char* path) (x<0||x>0xff)&&(x=-1); return r==1?x:-1; }; -#define err(e) {delete ret;return fprintf(stderr,"line %d: %s",ln,e),nullptr;} while(fgets(buf,1024,f)) { ++ln; @@ -232,17 +233,13 @@ void qmpMidiOutRtMidi::reset(uint8_t ch) if(ch==0xFF) { if(devinit) - { for(auto&msg:devinit->initseq.eventList) { if((msg.type&0xF0)==0xF0) extendedMessage(msg.str.length(),msg.str.data()); else - { basicMessage(msg.type,msg.p1,msg.p2); - } } - } } else { diff --git a/qmidiplayer-desktop/main.cpp b/qmidiplayer-desktop/main.cpp index ba44e99..37f6338 100644 --- a/qmidiplayer-desktop/main.cpp +++ b/qmidiplayer-desktop/main.cpp @@ -27,9 +27,6 @@ int main(int argc,char **argv) { -#ifdef _WIN32 - FreeConsole(); -#endif QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setApplicationName("qmidiplayer"); QCoreApplication::setApplicationVersion(APP_VERSION); @@ -52,8 +49,16 @@ int main(int argc,char **argv) clp.addPositionalArgument("file",QCoreApplication::translate("main","midi files to play (optional)."),"[files...]"); clp.addOption(QCommandLineOption("plugin",QCoreApplication::translate("main","Load a plugin from <plugin library>."),"plugin library")); clp.addOption(QCommandLineOption({"l","load-all-files"},QCoreApplication::translate("main","Load all files from the same folder."))); +#ifdef _WIN32 + clp.addOption(QCommandLineOption("keep-console",QCoreApplication::translate("main","Keep console window open."))); +#endif clp.process(a); +#ifdef _WIN32 + if(!clp.isSet("keep-console")) + FreeConsole(); +#endif + qmpMainWindow w(&clp); if(w.parseArgs()==1)return 0; w.init(); diff --git a/qmidiplayer-desktop/qmpdevpropdialog.cpp b/qmidiplayer-desktop/qmpdevpropdialog.cpp index 82136dc..64c385d 100644 --- a/qmidiplayer-desktop/qmpdevpropdialog.cpp +++ b/qmidiplayer-desktop/qmpdevpropdialog.cpp @@ -21,7 +21,7 @@ qmpDevPropDialog::qmpDevPropDialog(QWidget *parent) : this->ui->twProps->edit(ui->twProps->model()->index(r,c)); if(c==3) { - QString p=QFileDialog::getOpenFileUrl(this,"Select Device Initialization File",QUrl()).path(); + QString p=QFileDialog::getOpenFileUrl(this,"Select Device Initialization File",QUrl()).toLocalFile(); if(p.length())this->ui->twProps->item(r,2)->setText(p); } }); diff --git a/qmidiplayer-desktop/qmppresetselect.cpp b/qmidiplayer-desktop/qmppresetselect.cpp index 578ae1d..85dc893 100644 --- a/qmidiplayer-desktop/qmppresetselect.cpp +++ b/qmidiplayer-desktop/qmppresetselect.cpp @@ -27,7 +27,6 @@ void qmpPresetSelector::showEvent(QShowEvent *e) void qmpPresetSelector::setupWindow(int chid) { CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer(); - if(!plyr->fluid()->getSFCount())return; ch=chid;int r;char name[256]; uint16_t b;uint8_t p; std::string pstname; |