Skip to content

Commit

Permalink
Minor fixes to the way threadData is passed around.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Feb 1, 2018
1 parent 31f71f3 commit 0d8b4b0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 23 deletions.
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -119,10 +119,10 @@ MainWindow *MainWindow::instance(bool debug)
/*!
* \brief MainWindow::setUpMainWindow
* Creates all the GUI widgets.
* \param threadData
*/
void MainWindow::setUpMainWindow(threadData_t *threadData)
{
mpThreadData = threadData;
// Reopen the standard output stream.
QString outputFileName = Utilities::tempDirectory() + "/omeditoutput.txt";
freopen(outputFileName.toStdString().c_str(), "w", stdout);
Expand All @@ -143,7 +143,7 @@ void MainWindow::setUpMainWindow(threadData_t *threadData)
mpMessagesDockWidget->hide();
connect(MessagesWidget::instance(), SIGNAL(MessageAdded()), mpMessagesDockWidget, SLOT(show()));
// Create the OMCProxy object.
mpOMCProxy = new OMCProxy(this->mpThreadData, this);
mpOMCProxy = new OMCProxy(threadData, this);
if (getExitApplicationStatus()) {
return;
}
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -223,7 +223,6 @@ class MainWindow : public QMainWindow
const char* variables);
private:
bool mDebug;
threadData_t *mpThreadData;
OMCProxy *mpOMCProxy;
bool mExitApplicationStatus;
SearchWidget *mpSearchWidget;
Expand Down
18 changes: 4 additions & 14 deletions OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -63,16 +63,16 @@ void omc_Main_setWindowsPaths(threadData_t *threadData, void* _inOMHome);

/*!
* \class OMCProxy
* \brief It contains the reference of the CORBA object used to communicate with the OpenModelica Compiler.
* \brief Interface to send commands to OpenModelica Compiler.
*/
/*!
* \brief OMCProxy::OMCProxy
* \param threadData
* \param pParent
*/
OMCProxy::OMCProxy(threadData_t* threadData, QWidget *pParent )
OMCProxy::OMCProxy(threadData_t* threadData, QWidget *pParent)
: QObject(pParent), mHasInitialized(false), mResult(""), mTotalOMCCallsTime(0.0)
{
this->mpThreadData = threadData;
mCurrentCommandIndex = -1;
// OMC Commands Logger Widget
mpOMCLoggerWidget = new QWidget;
Expand Down Expand Up @@ -198,11 +198,8 @@ bool OMCProxy::initializeOMC(threadData_t *threadData)
void *args = mmc_mk_nil();
QString locale = "+locale=" + settingsLocale.name();
args = mmc_mk_cons(mmc_mk_scon(locale.toStdString().c_str()), args);
// initialize threadData
// initialize garbage collector
omc_System_initGarbageCollector(NULL);
//threadData_t *threadData = (threadData_t *) GC_malloc_uncollectable(sizeof(threadData_t));
//GC_add_roots(&threadData->localRoots[0], &threadData->localRoots[MAX_LOCAL_ROOTS]);
//memset(threadData, 0, sizeof(threadData_t));
MMC_TRY_TOP_INTERNAL()
omc_Main_init(threadData, args);
threadData->plotClassPointer = MainWindow::instance();
Expand Down Expand Up @@ -256,13 +253,6 @@ void OMCProxy::quitOMC()
*/
void OMCProxy::sendCommand(const QString expression)
{
if (!mHasInitialized) {
// if we are unable to start OMC. Exit the application.
if(!initializeOMC(mpThreadData)) {
MainWindow::instance()->setExitApplicationStatus(true);
return;
}
}
// write command to the commands log.
QTime commandTime;
commandTime.start();
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/OMC/OMCProxy.h
Expand Up @@ -81,7 +81,6 @@ class OMCProxy : public QObject
QMap<QString, QList<QString> > mDerivedUnitsMap;
OMCInterface *mpOMCInterface;
bool mIsLoggingEnabled;
threadData_t *mpThreadData;
public:
OMCProxy(threadData_t *threadData, QWidget *pParent = 0);
~OMCProxy();
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/OMEditApplication.cpp
Expand Up @@ -51,11 +51,11 @@
* \brief OMEditApplication::OMEditApplication
* \param argc
* \param argv
* \param threadData
*/
OMEditApplication::OMEditApplication(int &argc, char **argv, threadData_t* threadData)
: QApplication(argc, argv)
{
mpThreadData = threadData;
// set the stylesheet
setStyleSheet("file:///:/Resources/css/stylesheet.qss");
#if !(QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Expand Down
3 changes: 1 addition & 2 deletions OMEdit/OMEditGUI/OMEditApplication.h
Expand Up @@ -46,10 +46,9 @@ extern "C" {
class OMEditApplication : public QApplication
{
public:
OMEditApplication(int& argc, char**argv, threadData_t* threadData);
OMEditApplication(int& argc, char**argv, threadData_t *threadData);
private:
QStringList mFilesToOpenList;
threadData_t *mpThreadData;
protected:
virtual bool event(QEvent *pEvent);
};
Expand Down
3 changes: 1 addition & 2 deletions OMEdit/OMEditGUI/main.cpp
Expand Up @@ -145,10 +145,9 @@ void printOMEditUsage()

int main(int argc, char *argv[])
{
/* Do not use the signal handler OR exception filter if user is building a debug version. Perhaps the user wants to use gdb. */
MMC_INIT();
MMC_TRY_TOP()

/* Do not use the signal handler OR exception filter if user is building a debug version. Perhaps the user wants to use gdb. */
#ifdef QT_NO_DEBUG
#ifdef WIN32
SetUnhandledExceptionFilter(exceptionFilter);
Expand Down

0 comments on commit 0d8b4b0

Please sign in to comment.