From f3694385610a66215b65fafc1e05680baddeb090 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 16 Apr 2016 21:03:44 +0800 Subject: Fixed two bugs in initialization process. Documentation... --- qmidiplayer-desktop/main.cpp | 1 + qmidiplayer-desktop/qmpmainwindow.cpp | 33 +++++++++++++++++++-------------- qmidiplayer-desktop/qmpmainwindow.hpp | 3 ++- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'qmidiplayer-desktop') diff --git a/qmidiplayer-desktop/main.cpp b/qmidiplayer-desktop/main.cpp index 3a7e630..e763811 100644 --- a/qmidiplayer-desktop/main.cpp +++ b/qmidiplayer-desktop/main.cpp @@ -33,6 +33,7 @@ int main(int argc,char **argv) a.installTranslator(&qmpTranslator); qmpMainWindow w; if(w.pharseArgs(argc,argv)==1)return 0; + w.init(); return a.exec(); } diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp index 45ab634..b01df10 100644 --- a/qmidiplayer-desktop/qmpmainwindow.cpp +++ b/qmidiplayer-desktop/qmpmainwindow.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -45,9 +46,20 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : ui->lbFileName->setText("");ref=this; playing=false;stopped=true;dragging=false; settingsw=new qmpSettingsWindow(this); + plistw=new qmpPlistWindow(this);player=NULL;timer=NULL; singleFS=qmpSettingsWindow::getSettingsIntf()->value("Behavior/SingleInstance",0).toInt(); +} + +qmpMainWindow::~qmpMainWindow() +{ + if(player)delete player; + if(timer)delete timer; + delete ui; +} + +void qmpMainWindow::init() +{ player=new CMidiPlayer(singleFS); - plistw=new qmpPlistWindow(this); chnlw=new qmpChannelsWindow(this); efxw=new qmpEfxWindow(this); infow=new qmpInfoWindow(this); @@ -81,18 +93,12 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : connect(timer,SIGNAL(timeout()),this,SLOT(updateWidgets())); connect(timer,SIGNAL(timeout()),chnlw,SLOT(channelWindowsUpdate())); connect(timer,SIGNAL(timeout()),infow,SLOT(updateInfo())); -} - -qmpMainWindow::~qmpMainWindow() -{ - delete player; - delete timer; - delete ui; + if(havemidi)on_pbPlayPause_clicked(); } int qmpMainWindow::pharseArgs(int argc,char** argv) { - bool havemidi=false,loadfolder=false; + bool loadfolder=false;havemidi=false; for(int i=1;iemptyList();} if(loadfolder||qmpSettingsWindow::getSettingsIntf()->value("Behavior/LoadFolder",0).toInt()) { - QDirIterator di(QUrl(argv[i]).adjusted(QUrl::RemoveFilename).toString()); + QDirIterator di(QFileInfo(argv[i]).absolutePath()); while(di.hasNext()) { QString c=di.next(); @@ -132,7 +138,6 @@ int qmpMainWindow::pharseArgs(int argc,char** argv) plistw->insertItem(argv[i]); } } - if(havemidi)on_pbPlayPause_clicked(); return 0; } diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp index a409d2e..e17a792 100644 --- a/qmidiplayer-desktop/qmpmainwindow.hpp +++ b/qmidiplayer-desktop/qmpmainwindow.hpp @@ -29,6 +29,7 @@ class qmpMainWindow:public QMainWindow public: explicit qmpMainWindow(QWidget *parent = 0); + void init(); void closeEvent(QCloseEvent *event); void moveEvent(QMoveEvent *event); void dropEvent(QDropEvent *event); @@ -66,7 +67,7 @@ class qmpMainWindow:public QMainWindow private: Ui::qmpMainWindow *ui; QTimer *timer; - bool playing,stopped,dragging,fin,singleFS; + bool playing,stopped,dragging,fin,singleFS,havemidi; std::thread *playerTh=NULL; std::thread *renderTh=NULL; std::chrono::steady_clock::time_point st; -- cgit v1.2.3