mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 14:13:42 -07:00
big bugfix.
1. sometimes proxmark executes command twice... 2. start proxmark from QT was in a strange way( if we issue command very fast - it hangs
This commit is contained in:
parent
850f41650d
commit
d527d52411
4 changed files with 46 additions and 29 deletions
|
@ -56,7 +56,6 @@ extern "C" void MainGraphics(void)
|
|||
if (!gui)
|
||||
return;
|
||||
|
||||
main_loop_thread->start();
|
||||
gui->MainLoop();
|
||||
}
|
||||
|
||||
|
@ -70,18 +69,15 @@ extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char
|
|||
if (!useGUI)
|
||||
return;
|
||||
|
||||
gui = new ProxGuiQT(argc, argv);
|
||||
main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present);
|
||||
QObject::connect(main_loop_thread, SIGNAL(finished()), main_loop_thread, SLOT(deleteLater()));
|
||||
QObject::connect(main_loop_thread, SIGNAL(finished()), gui, SLOT(_Exit()));
|
||||
gui = new ProxGuiQT(argc, argv, main_loop_thread);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void ExitGraphics(void)
|
||||
{
|
||||
if (!gui)
|
||||
return;
|
||||
if (!gui)
|
||||
return;
|
||||
|
||||
gui->Exit();
|
||||
gui = NULL;
|
||||
gui->Exit();
|
||||
gui = NULL;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,17 @@ void ProxGuiQT::_Exit(void) {
|
|||
delete this;
|
||||
}
|
||||
|
||||
void ProxGuiQT::_StartProxmarkThread(void) {
|
||||
if (!proxmarkThread)
|
||||
return;
|
||||
|
||||
// if thread finished delete self and delete application
|
||||
QObject::connect(proxmarkThread, SIGNAL(finished()), proxmarkThread, SLOT(deleteLater()));
|
||||
QObject::connect(proxmarkThread, SIGNAL(finished()), this, SLOT(_Exit()));
|
||||
// start proxmark thread
|
||||
proxmarkThread->start();
|
||||
}
|
||||
|
||||
void ProxGuiQT::MainLoop()
|
||||
{
|
||||
plotapp = new QApplication(argc, argv);
|
||||
|
@ -94,11 +105,14 @@ void ProxGuiQT::MainLoop()
|
|||
connect(this, SIGNAL(HideGraphWindowSignal()), this, SLOT(_HideGraphWindow()));
|
||||
connect(this, SIGNAL(ExitSignal()), this, SLOT(_Exit()));
|
||||
|
||||
//start proxmark thread after starting event loop
|
||||
QTimer::singleShot(200, this, SLOT(_StartProxmarkThread()));
|
||||
|
||||
plotapp->exec();
|
||||
}
|
||||
|
||||
ProxGuiQT::ProxGuiQT(int argc, char **argv) : plotapp(NULL), plotwidget(NULL),
|
||||
argc(argc), argv(argv)
|
||||
ProxGuiQT::ProxGuiQT(int argc, char **argv, WorkerThread *wthread) : plotapp(NULL), plotwidget(NULL),
|
||||
argc(argc), argv(argv), proxmarkThread(wthread)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,18 @@ class ProxWidget : public QWidget
|
|||
void vchange_dthr_down(int v);
|
||||
};
|
||||
|
||||
class WorkerThread : public QThread {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
WorkerThread(char*, char*, bool);
|
||||
~WorkerThread();
|
||||
void run();
|
||||
private:
|
||||
char *script_cmds_file = NULL;
|
||||
char *script_cmd = NULL;
|
||||
bool usb_present;
|
||||
};
|
||||
|
||||
class ProxGuiQT : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
@ -98,9 +110,10 @@ class ProxGuiQT : public QObject
|
|||
int argc;
|
||||
char **argv;
|
||||
void (*main_func)(void);
|
||||
WorkerThread *proxmarkThread;
|
||||
|
||||
public:
|
||||
ProxGuiQT(int argc, char **argv);
|
||||
ProxGuiQT(int argc, char **argv, WorkerThread *wthread);
|
||||
~ProxGuiQT(void);
|
||||
void ShowGraphWindow(void);
|
||||
void RepaintGraphWindow(void);
|
||||
|
@ -112,6 +125,7 @@ class ProxGuiQT : public QObject
|
|||
void _RepaintGraphWindow(void);
|
||||
void _HideGraphWindow(void);
|
||||
void _Exit(void);
|
||||
void _StartProxmarkThread(void);
|
||||
signals:
|
||||
void ShowGraphWindowSignal(void);
|
||||
void RepaintGraphWindowSignal(void);
|
||||
|
@ -119,17 +133,4 @@ class ProxGuiQT : public QObject
|
|||
void ExitSignal(void);
|
||||
};
|
||||
|
||||
|
||||
class WorkerThread : public QThread {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
WorkerThread(char*, char*, bool);
|
||||
~WorkerThread();
|
||||
void run();
|
||||
private:
|
||||
char *script_cmds_file = NULL;
|
||||
char *script_cmd = NULL;
|
||||
bool usb_present;
|
||||
};
|
||||
|
||||
#endif // PROXGUI_QT
|
||||
|
|
|
@ -122,6 +122,7 @@ void main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
|||
read_history(".history");
|
||||
|
||||
while(1) {
|
||||
break;
|
||||
|
||||
// If there is a script file
|
||||
if (script_file)
|
||||
|
@ -140,13 +141,18 @@ void main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
|||
if ((cmd = (char*) malloc(strlen(script_cmd_buf) + 1)) != NULL) {
|
||||
memset(cmd, 0, strlen(script_cmd_buf));
|
||||
strcpy(cmd, script_cmd_buf);
|
||||
printf("%s\n", cmd);
|
||||
printf(PROXPROMPT"%s\n", cmd);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If there is a script command
|
||||
if (execCommand){
|
||||
cmd = script_cmd;
|
||||
if ((cmd = (char*) malloc(strlen(script_cmd) + 1)) != NULL) {
|
||||
memset(cmd, 0, strlen(script_cmd));
|
||||
strcpy(cmd, script_cmd);
|
||||
printf(PROXPROMPT"%s\n", cmd);
|
||||
}
|
||||
|
||||
execCommand = false;
|
||||
} else {
|
||||
// exit after exec command
|
||||
|
@ -172,12 +178,13 @@ void main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
|||
}
|
||||
}
|
||||
free(cmd);
|
||||
cmd = NULL;
|
||||
} else {
|
||||
printf("\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
write_history(".history");
|
||||
|
||||
if (usb_present) {
|
||||
|
@ -189,7 +196,6 @@ void main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
|||
fclose(script_file);
|
||||
script_file = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void dumpAllHelp(int markdown)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue