Skip to content

Commit

Permalink
- Re-implement start & exit to handle Thread loop.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25434 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 7, 2015
1 parent ad75c46 commit 41b3823
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 1 addition & 2 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -88,7 +88,7 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, QWidget *parent)
mpMessagesDockWidget->hide();
connect(mpMessagesWidget, SIGNAL(MessageAdded()), mpMessagesDockWidget, SLOT(show()));
// Reopen the standard output stream.
QString outputFileName = mpOMCProxy->changeDirectory()+ "/OMEditOutput.txt";
QString outputFileName = mpOMCProxy->changeDirectory()+ "/omeditoutput.txt";
freopen(outputFileName.toStdString().c_str(), "w", stdout);
setbuf(stdout, NULL); // used non-buffered stdout
mpOutputFileDataNotifier = 0;
Expand Down Expand Up @@ -585,7 +585,6 @@ void MainWindow::beforeClosingMainWindow()
{
mpOMCProxy->quitOMC();
if (mpOutputFileDataNotifier) {
mpOutputFileDataNotifier->stop();
mpOutputFileDataNotifier->exit();
mpOutputFileDataNotifier->wait();
delete mpOutputFileDataNotifier;
Expand Down
24 changes: 24 additions & 0 deletions OMEdit/OMEditGUI/Util/Utilities.cpp
Expand Up @@ -67,6 +67,18 @@ FileDataNotifier::FileDataNotifier(const QString fileName)
mBytesAvailable = 0;
}

/*!
* \brief FileDataNotifier::exit
* Reimplementation of QThread::exit()
* Sets mStop to true.
* \param retcode
*/
void FileDataNotifier::exit(int retcode)
{
mStop = true;
QThread::exit(retcode);
}

/*!
* \brief FileDataNotifier::run
* Reimplentation of QThread::run().
Expand All @@ -91,6 +103,18 @@ void FileDataNotifier::run()
}
}

/*!
* \brief FileDataNotifier::start
* Reimplementation of QThread::start()
* Sets mStop to false.
* \param priority
*/
void FileDataNotifier::start(Priority priority)
{
mStop = false;
QThread::start(priority);
}

Label::Label(QWidget *parent, Qt::WindowFlags flags)
: QLabel(parent, flags), mElideMode(Qt::ElideNone), mText("")
{
Expand Down
4 changes: 3 additions & 1 deletion OMEdit/OMEditGUI/Util/Utilities.h
Expand Up @@ -75,13 +75,15 @@ class FileDataNotifier : public QThread
Q_OBJECT
public:
FileDataNotifier(const QString fileName);
void stop() {mStop = true;}
void exit(int retcode = 0);
private:
QFile mFile;
bool mStop;
qint64 mBytesAvailable;
protected:
void run();
public slots:
void start(Priority = InheritPriority);
signals:
void bytesAvailable(qint64 bytes);
};
Expand Down

0 comments on commit 41b3823

Please sign in to comment.