Changeset 388377b in OpenModelica for OMEdit/OMEditLIB/MainWindow.cpp


Ignore:
Timestamp:
2023-03-24T14:56:17+01:00 (14 months ago)
Author:
Adeel Asghar <adeel.asghar@…>
Children:
a498414e
Parents:
c84168c
Message:

Write the instance api profiling to a file instanceApiProfiling.txt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OMEdit/OMEditLIB/MainWindow.cpp

    r7f0681b2 r388377b  
    408408}
    409409
     410/*!
     411 * \brief MainWindow::setNewApiProfiling
     412 * Sets the new api profiling flag.
     413 * If flag is enabled then creates a file for it.
     414 * \param newApiProfiling
     415 */
     416void MainWindow::setNewApiProfiling(bool newApiProfiling)
     417{
     418  mNewApiProfiling = newApiProfiling;
     419  if (mNewApiProfiling) {
     420    QString& tmpPath = Utilities::tempDirectory();
     421    /* create a file to write OMEdit communication log */
     422    QString profilingFilePath = QString("%1instanceApiProfiling.txt").arg(tmpPath);
     423#ifdef Q_OS_WIN
     424    mpNewApiProfilingFile = _wfopen((wchar_t*)profilingFilePath.utf16(), L"w");
     425#else
     426    mpNewApiProfilingFile = fopen(profilingFilePath.toUtf8().constData(), "w");
     427#endif
     428  }
     429}
     430
    410431#if !defined(WITHOUT_OSG)
    411432/*!
     
    678699  // delete the searchwidget object to call the destructor, to cancel the search operation running on seperate thread
    679700  delete mpSearchWidget;
     701  // if new api profiling file is open then close it.
     702  if (mpNewApiProfilingFile) {
     703    fclose(mpNewApiProfilingFile);
     704  }
    680705}
    681706
     
    15381563{
    15391564  return QString("%1/.openmodelica/libraries/index.json").arg(Helper::userHomeDirectory);
     1565}
     1566
     1567/*!
     1568 * \brief MainWindow::writeNewApiProfiling
     1569 * Writes to new api profiling file.
     1570 * \param str
     1571 */
     1572void MainWindow::writeNewApiProfiling(const QString &str)
     1573{
     1574  if (mpNewApiProfilingFile) {
     1575    fputs(QString("%1\n").arg(str).toUtf8().constData(), mpNewApiProfilingFile);
     1576    fflush(mpNewApiProfilingFile);
     1577  }
    15401578}
    15411579
Note: See TracChangeset for help on using the changeset viewer.