- enhancement: detach pausing console window
- use "-var-update" gdb command instead of "noop"
This commit is contained in:
parent
8ea5a2d5ba
commit
13c79bb55d
1
NEWS.md
1
NEWS.md
|
@ -8,6 +8,7 @@ Version 0.12.5 For Dev-C++ 7 Beta
|
|||
- fix: wrong executable filename for source files in linux
|
||||
- enhancement: console pauser for linux
|
||||
- enhancement: redirect input to program in linux
|
||||
- enhancement: detach pausing console window
|
||||
|
||||
Version 0.12.4 For Dev-C++ 7 Beta
|
||||
- change: add copyright infos to each source file
|
||||
|
|
|
@ -276,6 +276,7 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
|
|||
connect(mRunner, &Runner::finished, mRunner ,&Runner::deleteLater);
|
||||
connect(mRunner, &Runner::finished, pMainWindow ,&MainWindow::onRunFinished);
|
||||
connect(mRunner, &Runner::pausingForFinish, pMainWindow ,&MainWindow::onRunPausingForFinish);
|
||||
connect(mRunner, &Runner::pausingForFinish, this ,&CompilerManager::onRunnerPausing);
|
||||
connect(mRunner, &Runner::runErrorOccurred, pMainWindow ,&MainWindow::onRunErrorOccured);
|
||||
mRunner->start();
|
||||
}
|
||||
|
@ -325,13 +326,17 @@ void CompilerManager::stopRun()
|
|||
}
|
||||
}
|
||||
|
||||
void CompilerManager::stopAllRunners()
|
||||
{
|
||||
emit signalStopAllRunners();
|
||||
}
|
||||
|
||||
void CompilerManager::stopPausing()
|
||||
{
|
||||
QMutexLocker locker(&mRunnerMutex);
|
||||
if (mRunner!=nullptr && mRunner->pausing()) {
|
||||
disconnect(mRunner, &Runner::finished, this ,&CompilerManager::onRunnerTerminated);
|
||||
mRunner->stop();
|
||||
disconnect(mRunner, &Runner::finished, this ,&CompilerManager::onRunnerTerminated);
|
||||
mRunner=nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -368,6 +373,16 @@ void CompilerManager::onRunnerTerminated()
|
|||
mRunner=nullptr;
|
||||
}
|
||||
|
||||
void CompilerManager::onRunnerPausing()
|
||||
{
|
||||
QMutexLocker locker(&mRunnerMutex);
|
||||
disconnect(mRunner, &Runner::finished, this ,&CompilerManager::onRunnerTerminated);
|
||||
disconnect(mRunner, &Runner::finished, pMainWindow ,&MainWindow::onRunFinished);
|
||||
disconnect(mRunner, &Runner::runErrorOccurred, pMainWindow ,&MainWindow::onRunErrorOccured);
|
||||
connect(this, &CompilerManager::signalStopAllRunners, mRunner, &Runner::stop);
|
||||
mRunner=nullptr;
|
||||
}
|
||||
|
||||
void CompilerManager::onCompileIssue(PCompileIssue issue)
|
||||
{
|
||||
if (issue->type == CompileIssueType::Error)
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
void runProblem(const QString& filename, const QString& arguments, const QString& workDir, POJProblemCase problemCase);
|
||||
void runProblem(const QString& filename, const QString& arguments, const QString& workDir, QVector<POJProblemCase> problemCases);
|
||||
void stopRun();
|
||||
void stopAllRunners();
|
||||
void stopPausing();
|
||||
void stopCompile();
|
||||
void stopCheckSyntax();
|
||||
|
@ -58,8 +59,12 @@ public:
|
|||
|
||||
int syntaxCheckIssueCount() const;
|
||||
|
||||
signals:
|
||||
void signalStopAllRunners();
|
||||
|
||||
private slots:
|
||||
void onRunnerTerminated();
|
||||
void onRunnerPausing();
|
||||
void onCompileFinished();
|
||||
void onCompileIssue(PCompileIssue issue);
|
||||
void onSyntaxCheckFinished();
|
||||
|
|
|
@ -35,9 +35,9 @@ ExecutableRunner::ExecutableRunner(const QString &filename, const QString &argum
|
|||
,QObject* parent):
|
||||
Runner(filename,arguments,workDir,parent),
|
||||
mRedirectInput(false),
|
||||
mStartConsole(false)
|
||||
mStartConsole(false),
|
||||
mQuitSemaphore(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ExecutableRunner::startConsole() const
|
||||
|
@ -192,6 +192,25 @@ void ExecutableRunner::run()
|
|||
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
|
||||
if (mStartConsole && !mPausing && pBuf) {
|
||||
if (strncmp(pBuf,"FINISHED",sizeof("FINISHED"))==0) {
|
||||
#ifdef Q_OS_WIN
|
||||
if (pBuf) {
|
||||
UnmapViewOfFile(pBuf);
|
||||
pBuf = nullptr;
|
||||
}
|
||||
if (hSharedMemory!=INVALID_HANDLE_VALUE) {
|
||||
hSharedMemory = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(hSharedMemory);
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
if (pBuf) {
|
||||
munmap(pBuf,BUF_SIZE);
|
||||
pBuf = nullptr;
|
||||
}
|
||||
if (fd_shm!=-1) {
|
||||
shm_unlink("/REDPANDAIDECONSOLEPAUSER20211223");
|
||||
fd_shm = -1;
|
||||
}
|
||||
#endif
|
||||
setPausing(true);
|
||||
emit pausingForFinish();
|
||||
}
|
||||
|
@ -236,39 +255,10 @@ void ExecutableRunner::run()
|
|||
break;
|
||||
}
|
||||
}
|
||||
mQuitSemaphore.release(1);
|
||||
}
|
||||
|
||||
void ExecutableRunner::doStop()
|
||||
{
|
||||
std::shared_ptr<QProcess> process = mProcess;
|
||||
if (process) {
|
||||
// qDebug()<<"??1";
|
||||
// process->closeReadChannel(QProcess::StandardOutput);
|
||||
// process->closeReadChannel(QProcess::StandardError);
|
||||
// process->closeWriteChannel();
|
||||
// qDebug()<<"??2";
|
||||
// #ifdef Q_OS_WIN
|
||||
// if (!mStartConsole) {
|
||||
// qDebug()<<"??3";
|
||||
// process->terminate();
|
||||
// qDebug()<<"??4";
|
||||
// if (process->waitForFinished(1000)) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// #else
|
||||
// process->terminate();
|
||||
// if (process->waitForFinished(1000)) {
|
||||
// break;
|
||||
// }
|
||||
// #endif
|
||||
// for (int i=0;i<10;i++) {
|
||||
// qDebug()<<"??5";
|
||||
// process->kill();
|
||||
// qDebug()<<"??6";
|
||||
// if (process->waitForFinished(100)) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
mQuitSemaphore.acquire(1);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "runner.h"
|
||||
#include <QProcess>
|
||||
#include <QSemaphore>
|
||||
|
||||
class ExecutableRunner : public Runner
|
||||
{
|
||||
|
@ -41,6 +42,7 @@ private:
|
|||
bool mRedirectInput;
|
||||
bool mStartConsole;
|
||||
std::shared_ptr<QProcess> mProcess;
|
||||
QSemaphore mQuitSemaphore;
|
||||
|
||||
// QThread interface
|
||||
protected:
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "runner.h"
|
||||
#include <QDebug>
|
||||
|
||||
Runner::Runner(const QString &filename, const QString &arguments, const QString &workDir
|
||||
,QObject *parent) : QThread(parent),
|
||||
|
|
|
@ -1241,7 +1241,7 @@ void DebugReader::asyncUpdate()
|
|||
{
|
||||
QMutexLocker locker(&mCmdQueueMutex);
|
||||
if (mCmdQueue.isEmpty())
|
||||
postCommand("noop","",DebugCommandSource::Other);
|
||||
postCommand("-var-update"," --all-values *",DebugCommandSource::Other);
|
||||
mAsyncUpdated = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3655,6 +3655,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||
}
|
||||
|
||||
mTcpServer.close();
|
||||
mCompilerManager->stopAllRunners();
|
||||
mCompilerManager->stopCompile();
|
||||
mCompilerManager->stopRun();
|
||||
if (!mShouldRemoveAllSettings)
|
||||
|
|
Loading…
Reference in New Issue