dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
vlp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1fda21e
)
VLP-28 Block remaining menu entries on console lock.
author
Rafał Długołęcki
<kontakt@dlugolecki.net.pl>
Mon, 28 Oct 2013 19:13:26 +0000
(20:13 +0100)
committer
Rafał Długołęcki
<kontakt@dlugolecki.net.pl>
Mon, 28 Oct 2013 19:13:26 +0000
(20:13 +0100)
src/kernel/kernel.cpp
patch
|
blob
|
history
diff --git
a/src/kernel/kernel.cpp
b/src/kernel/kernel.cpp
index 8ab19f17dcbda4cd62500b724e63a2e62e15195a..969156fed849fd142d95d83ca20ac8ab6be992b9 100644
(file)
--- a/
src/kernel/kernel.cpp
+++ b/
src/kernel/kernel.cpp
@@
-49,6
+49,7
@@
#include <qfile.h>
#include <qcursor.h>
#include <QtCore/QSocketNotifier>
#include <qfile.h>
#include <qcursor.h>
#include <QtCore/QSocketNotifier>
+#include <QtGui/QCloseEvent>
#include <qdir.h>
#include <stdio.h>
#include <qdir.h>
#include <stdio.h>
@@
-187,10
+188,13
@@
private:
QAction * qid;
QAction * cwid;
QAction * optid;
QAction * qid;
QAction * cwid;
QAction * optid;
- QAction * prid;
- QAction * mid;
+ QAction * programExecuteAction;
+ QAction * programKillAction;
+ QAction * machineMessageAction;
+ QAction * machineConnectAction;
+ QAction * machineDisconnectAction;
+ QAction * machineInfoAction;
QAction * msgid;
QAction * msgid;
- QAction * toolsid;
QAction * hid;
int net_sock;
QAction * hid;
int net_sock;
@@
-215,7
+219,11
@@
private:
*/
void QKernel::closeEvent(QCloseEvent * e)
{
*/
void QKernel::closeEvent(QCloseEvent * e)
{
- QuitProc();
+ e->ignore();
+
+ if (!LOCKED) {
+ QuitProc();
+ }
}
/**
}
/**
@@
-239,16
+247,15
@@
QKernel::QKernel()
QMenu * programMenu = NULL;
programMenu = menuBar()->addMenu("&Program");
QMenu * programMenu = NULL;
programMenu = menuBar()->addMenu("&Program");
- programMenu->addAction("Execute", this, SLOT(Run_Prog()));
- programMenu->addAction("Kill", this, SLOT(KillInterpreter()));
-
+ programExecuteAction = programMenu->addAction("Execute", this, SLOT(Run_Prog()));
+ programKillAction = programMenu->addAction("Kill", this, SLOT(KillInterpreter()));
machineMenu = menuBar()->addMenu("&Machine");
machineMenu = menuBar()->addMenu("&Machine");
- machineMenu->addAction("Message", this, SLOT(MessageToNode()));
+ machineMe
ssageAction = machineMe
nu->addAction("Message", this, SLOT(MessageToNode()));
machineMenu->addSeparator();
machineMenu->addSeparator();
- machineMenu->addAction("Connect", this, SLOT(Connect()));
- machineMenu->addAction("Disconnect", this, SLOT(Disconnect()));
- machineMenu->addAction("Info", this, SLOT(Info()));
+ machine
ConnectAction = machine
Menu->addAction("Connect", this, SLOT(Connect()));
+ machine
DisconnectAction = machine
Menu->addAction("Disconnect", this, SLOT(Disconnect()));
+ machine
InfoAction = machine
Menu->addAction("Info", this, SLOT(Info()));
toolsMenu = menuBar()->addMenu("&Tools");
cwid = toolsMenu->addAction("Editor", this, SLOT(Edit()));
toolsMenu = menuBar()->addMenu("&Tools");
cwid = toolsMenu->addAction("Editor", this, SLOT(Edit()));
@@
-571,24
+578,25
@@
void QKernel::QuitProc()
{
MESSAGE msg;
{
MESSAGE msg;
- if (QMessageBox::question(this, "Close VLP", "Terminate VLP ?",
- QMessageBox::Yes, QMessageBox::No, 0) == QMessageBox::No) {
+ QMessageBox::StandardButton response;
+ response = QMessageBox::question(this, "Close VLP", "Terminate VLP ?",
+ QMessageBox::Ok | QMessageBox::Cancel);
+
+
+ if (response == QMessageBox::Cancel) {
return;
}
return;
}
-
- if (!LOCKED) {
- /*
- msg.msg_type = MSG_NET;
- msg.param.pword[0] = NET_DISCONNECT;
- write(net_sock, &msg, sizeof(MESSAGE));*/
- delete Net_Notify;
-
- msg.msg_type = MSG_NET;
- msg.param.pword[0] = NET_EXIT;
- write(net_sock, &msg, sizeof(MESSAGE));
- /* ::close(net_sock);*/
- app->quit();
- }
+ /*
+ msg.msg_type = MSG_NET;
+ msg.param.pword[0] = NET_DISCONNECT;
+ write(net_sock, &msg, sizeof(MESSAGE));*/
+ delete Net_Notify;
+
+ msg.msg_type = MSG_NET;
+ msg.param.pword[0] = NET_EXIT;
+ write(net_sock, &msg, sizeof(MESSAGE));
+ /* ::close(net_sock);*/
+ app->quit();
}
/**
}
/**
@@
-1140,15
+1148,29
@@
void QKernel::LockConsole()
strcpy(LockPasswd, ed.text().toAscii().data());
lab.setText("Retype:");
ed.setText("");
strcpy(LockPasswd, ed.text().toAscii().data());
lab.setText("Retype:");
ed.setText("");
+ /*
+ * Following exec(), could produce error:
+ * X Error: BadWindow (invalid Window parameter) 3
+ * Major opcode: 3 (X_GetWindowAttributes)
+ *
+ * This is not error in our code. Basing on:
+ * https://bugreports.qt-project.org/browse/QTBUG-1782
+ * this happens only on Qt 4.3 - 4.4.
+ */
if (d.exec()) {
if (d.exec()) {
- if (strcmp(ed.text().toAscii().data(), LockPasswd)==0) {
- qid->setEnabled(FALSE);
- prid->setEnabled(FALSE);
- mid->setEnabled(FALSE);
+ if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
+ qid->setDisabled(TRUE);
+ programExecuteAction->setDisabled(TRUE);
+ programKillAction->setDisabled(TRUE);
+ machineMessageAction->setDisabled(TRUE);
+ machineConnectAction->setDisabled(TRUE);
+ machineDisconnectAction->setDisabled(TRUE);
+ machineInfoAction->setDisabled(TRUE);
+
unlockid->setEnabled(TRUE);
unlockid->setEnabled(TRUE);
- lockid->set
Enabled(FALS
E);
- cwid->set
Enabled(FALS
E);
- optid->set
Enabled(FALS
E);
+ lockid->set
Disabled(TRU
E);
+ cwid->set
Disabled(TRU
E);
+ optid->set
Disabled(TRU
E);
WriteMessage("CONSOLE LOCKED");
LOCKED = TRUE;
} else {
WriteMessage("CONSOLE LOCKED");
LOCKED = TRUE;
} else {
@@
-1195,8
+1217,12
@@
void QKernel::UnlockConsole()
if (d.exec()) {
if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
qid->setEnabled(TRUE);
if (d.exec()) {
if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
qid->setEnabled(TRUE);
- prid->setEnabled(TRUE);
- mid->setEnabled(TRUE);
+ programExecuteAction->setEnabled(TRUE);
+ programKillAction->setEnabled(TRUE);
+ machineMessageAction->setEnabled(TRUE);
+ machineConnectAction->setEnabled(TRUE);
+ machineDisconnectAction->setEnabled(TRUE);
+ machineInfoAction->setEnabled(TRUE);
unlockid->setEnabled(FALSE);
lockid->setEnabled(TRUE);
cwid->setEnabled(TRUE);
unlockid->setEnabled(FALSE);
lockid->setEnabled(TRUE);
cwid->setEnabled(TRUE);
@@
-1331,7
+1357,7
@@
InterpEntry *QKernel::RunIntModule(char *ss, int r)
len = strlen(svr.sun_path)+sizeof(svr.sun_family);
bind(sock, (struct sockaddr*)&svr, len);
listen(sock, 5);
len = strlen(svr.sun_path)+sizeof(svr.sun_family);
bind(sock, (struct sockaddr*)&svr, len);
listen(sock, 5);
- system(cmd);
+ system(cmd);
newINT->sock = accept(sock, (struct sockaddr*)0, (unsigned int *)0);
//::close(sock);
newINT->sock = accept(sock, (struct sockaddr*)0, (unsigned int *)0);
//::close(sock);
@@
-1340,7
+1366,7
@@
InterpEntry *QKernel::RunIntModule(char *ss, int r)
O_NONBLOCK|fcntl(newINT->sock, F_GETFL, 0));
on=1;
setsockopt(newINT->sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on,
O_NONBLOCK|fcntl(newINT->sock, F_GETFL, 0));
on=1;
setsockopt(newINT->sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on,
- sizeof(on));
+ sizeof(on));
if (r)
newINT->remote = 1;
else
if (r)
newINT->remote = 1;
else
@@
-1419,7
+1445,7
@@
void QKernel::RemoteInstance(InterpEntry *interp, int on)
interp->RInstances[on] = m.param.pword[7];
break;
}
interp->RInstances[on] = m.param.pword[7];
break;
}
- read(net_sock, &m, sizeof(MESSAGE));
+ read(net_sock, &m, sizeof(MESSAGE));
}
Net_Notify->setEnabled(TRUE);
}
Net_Notify->setEnabled(TRUE);