From 263987014ca29ee85fd605529db7b3cd4ca05871 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 29 Mar 2009 02:12:15 +0000 Subject: [PATCH] Add lots of debugging output to show which director many of the debug messages are for. Add a timer to wait 2 seconds before querying the director for lists. Take more control of the wait state of the application prevent users from doing things they shouldn't. Still have more to do with the restore screen with wait state's git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8634 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/bcomm/dircomm.cpp | 34 +++++++------ bacula/src/qt-console/console/console.cpp | 50 ++++++++++++-------- bacula/src/qt-console/jobs/jobs.cpp | 2 + bacula/src/qt-console/mainwin.cpp | 26 +++++++--- bacula/src/qt-console/mainwin.h | 3 ++ bacula/src/qt-console/util/fmtwidgetitem.cpp | 2 - 6 files changed, 71 insertions(+), 46 deletions(-) diff --git a/bacula/src/qt-console/bcomm/dircomm.cpp b/bacula/src/qt-console/bcomm/dircomm.cpp index 0fdcfb7933..82e71a4785 100644 --- a/bacula/src/qt-console/bcomm/dircomm.cpp +++ b/bacula/src/qt-console/bcomm/dircomm.cpp @@ -67,6 +67,8 @@ void DirComm::terminate() delete m_notifier; m_notifier = NULL; } + if (mainWin->m_connDebug) + Pmsg2(000, "DirComm %i terminating connections %s\n", m_conn, m_console->m_dir->name()); m_sock->close(); m_sock = NULL; } @@ -89,7 +91,7 @@ bool DirComm::connect_dir() m_console->display_textf(_("Already connected\"%s\".\n"), m_console->m_dir->name()); if (mainWin->m_connDebug) - Pmsg1(000, "DirComm %i BAILING already connected\n", m_conn); + Pmsg2(000, "DirComm %i BAILING already connected %s\n", m_conn, m_console->m_dir->name()); goto bail_out; } @@ -124,7 +126,7 @@ bool DirComm::connect_dir() m_console->display_textf(_("Failed to initialize TLS context for Console \"%s\".\n"), m_console->m_dir->name()); if (mainWin->m_connDebug) - Pmsg1(000, "DirComm %i BAILING Failed to initialize TLS context for Console \n", m_conn); + Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Console %s\n", m_conn, m_console->m_dir->name()); goto bail_out; } } @@ -147,7 +149,7 @@ bool DirComm::connect_dir() m_console->m_dir->name()); mainWin->set_status("Connection failed"); if (mainWin->m_connDebug) - Pmsg1(000, "DirComm %i BAILING Failed to initialize TLS context for Director \n", m_conn); + Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Director %s\n", m_conn, m_console->m_dir->name()); goto bail_out; } } @@ -166,7 +168,7 @@ bool DirComm::connect_dir() if (m_sock == NULL) { mainWin->set_status("Connection failed"); if (mainWin->m_connDebug) - Pmsg1(000, "DirComm %i BAILING Connection failed\n", m_conn); + Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name()); goto bail_out; } else { /* Update page selector to green to indicate that Console is connected */ @@ -181,7 +183,7 @@ bool DirComm::connect_dir() if (!authenticate_director(jcr, m_console->m_dir, cons, buf, sizeof(buf))) { m_console->display_text(buf); if (mainWin->m_connDebug) - Pmsg1(000, "DirComm %i BAILING Connection failed\n", m_conn); + Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name()); goto bail_out; } @@ -209,12 +211,12 @@ bool DirComm::connect_dir() mainWin->set_status(_("Connected")); if (mainWin->m_connDebug) - Pmsg1(000, "Returning TRUE from DirComm->connect_dir : %i\n", m_conn); + Pmsg2(000, "Returning TRUE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name()); return true; bail_out: if (mainWin->m_connDebug) - Pmsg1(000, "Returning FALSE from DirComm->connect_dir : %i\n", m_conn); + Pmsg2(000, "Returning FALSE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name()); delete jcr; return false; } @@ -322,29 +324,24 @@ int DirComm::read() m_at_prompt = true; m_at_main_prompt = true; mainWin->set_status(_("At main prompt waiting for input ...")); - QApplication::restoreOverrideCursor(); break; case BNET_PROMPT: if (mainWin->m_commDebug) Pmsg1(000, "conn %i PROMPT\n", m_conn); m_at_prompt = true; m_at_main_prompt = false; mainWin->set_status(_("At prompt waiting for input ...")); - QApplication::restoreOverrideCursor(); break; case BNET_CMD_FAILED: if (mainWin->m_commDebug) Pmsg1(000, "CMD FAILED\n", m_conn); if (--m_in_command < 0) { -// Pmsg0(000, "m_in_command < 0\n"); m_in_command = 0; } mainWin->set_status(_("Command failed.")); - QApplication::restoreOverrideCursor(); break; /* We should not get this one */ case BNET_EOD: if (mainWin->m_commDebug) Pmsg1(000, "conn %i EOD\n", m_conn); mainWin->set_status_ready(); - QApplication::restoreOverrideCursor(); if (!m_api_set) { break; } @@ -402,7 +399,7 @@ int DirComm::read() m_notifier = NULL; } mainWin->set_status(_("Director disconnected.")); - QApplication::restoreOverrideCursor(); +// QApplication::restoreOverrideCursor(); stat = BNET_HARDEOF; } break; @@ -435,13 +432,14 @@ bool DirComm::notify(bool enable) if (m_notifier) { prev_enabled = m_notifier->isEnabled(); m_notifier->setEnabled(enable); - if (mainWin->m_connDebug) + if (mainWin->m_connDebug) { if (prev_enabled && !enable) - Pmsg1(000, "m_notifier Disabling notifier: %i\n", m_conn); + Pmsg2(000, "m_notifier Disabling notifier: %i %s\n", m_conn, m_console->m_dir->name()); else if (!prev_enabled && enable) - Pmsg1(000, "m_notifier Enabling notifier: %i\n", m_conn); - } else if (mainWin->m_connDebug) - Pmsg1(000, "m_notifier does not exist: %i\n", m_conn); + Pmsg2(000, "m_notifier Enabling notifier: %i %s\n", m_conn, m_console->m_dir->name()); + } + } else if (mainWin->m_connDebug) + Pmsg2(000, "m_notifier does not exist: %i %s\n", m_conn, m_console->m_dir->name()); return prev_enabled; } diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 2ab3f35584..25a5b1305f 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -121,10 +121,9 @@ void Console::connect_dir() if (dircomm->connect_dir()) { if (mainWin->m_connDebug) - Pmsg0(000, "DirComm 0 Seems to have Connected\n"); + Pmsg1(000, "DirComm 0 Seems to have Connected %s\n", m_dir->name()); beginNewCommand(0); } - populateLists(true); mainWin->set_status(_("Connected")); startTimer(); /* start message timer */ @@ -139,12 +138,12 @@ void Console::populateLists(bool forcenew) int conn; if (forcenew) { if (!newDirComm(conn)) { - Pmsg0(000, "newDirComm Seems to Failed to create a connection for populateLists\n"); + Pmsg1(000, "newDirComm Seems to Failed to create a connection for populateLists %s\n", m_dir->name()); return; } } else { if(!availableDirComm(conn)) { - Pmsg0(000, "availableDirComm Seems to Failed to find a connection for populateLists\n"); + Pmsg1(000, "availableDirComm Seems to Failed to find a connection for populateListsi %s\n", m_dir->name()); return; } } @@ -172,11 +171,11 @@ void Console::populateLists(int conn) dir_cmd(conn, ".levels", level_list); if (mainWin->m_connDebug) { - QString dbgmsg = QString("jobs=%1 clients=%2 filesets=%3 msgs=%4 pools=%5 storage=%6 types=%7 levels=%8 conn=%9\n") + QString dbgmsg = QString("jobs=%1 clients=%2 filesets=%3 msgs=%4 pools=%5 storage=%6 types=%7 levels=%8 conn=%9 %10\n") .arg(job_list.count()).arg(client_list.count()).arg(fileset_list.count()).arg(messages_list.count()) .arg(pool_list.count()).arg(storage_list.count()).arg(type_list.count()).arg(level_list.count()) - .arg(conn); - Pmsg1(000, "%s\n", dbgmsg.toUtf8().data()); + .arg(conn).arg(m_dir->name()); + Pmsg1(000, "%s", dbgmsg.toUtf8().data()); } } @@ -199,7 +198,7 @@ bool Console::dir_cmd(const char *cmd, QStringList &results) dir_cmd(conn, cmd, results); return true; } else { - Pmsg0(000, "dir_cmd Seems to Failed to find a connection\n"); + Pmsg1(000, "dir_cmd Seems to Failed to find a connection %s\n", m_dir->name()); return false; } } @@ -214,8 +213,10 @@ bool Console::dir_cmd(int conn, const char *cmd, QStringList &results) DirComm *dircomm = m_dircommHash.value(conn); int stat; - if (mainWin->m_connDebug) - Pmsg2(000, "dir_cmd conn %i %s\n", conn, cmd); + if (mainWin->m_connDebug) { + QString dbgmsg = QString("dir_cmd conn %1 %2 %3\n").arg(conn).arg(m_dir->name()).arg(cmd); + Pmsg1(000, "%s", dbgmsg.toUtf8().data()); + } notify(conn, false); dircomm->write(cmd); while ((stat = dircomm->read()) > 0 && dircomm->is_in_command()) { @@ -359,8 +360,11 @@ bool Console::get_job_defaults(int &conn, struct job_defaults &job_defs, bool do conn = notifyOff(); beginNewCommand(conn); DirComm *dircomm = m_dircommHash.value(conn); + bool prevWaitState = mainWin->getWaitState(); + if (!prevWaitState) + mainWin->waitEnter(); if (mainWin->m_connDebug) - Pmsg1(000, "job_defaults conn %i\n", conn); + Pmsg2(000, "job_defaults conn %i %s\n", conn, m_dir->name()); scmd = QString(".defaults job=\"%1\"").arg(job_defs.job_name); dircomm->write(scmd); while ((stat = dircomm->read()) > 0) { @@ -423,11 +427,15 @@ bool Console::get_job_defaults(int &conn, struct job_defaults &job_defs, bool do if (donotify) notify(conn, true); + if (!prevWaitState) + mainWin->waitExit(); return true; bail_out: if (donotify) notify(conn, true); + if (!prevWaitState) + mainWin->waitExit(); return false; } @@ -539,7 +547,7 @@ void Console::display_html(const QString buf) /* Position cursor to end of screen */ void Console::update_cursor() { - QApplication::restoreOverrideCursor(); +// QApplication::restoreOverrideCursor(); m_textEdit->moveCursor(QTextCursor::End); m_textEdit->ensureCursorVisible(); } @@ -551,6 +559,7 @@ void Console::beginNewCommand(int conn) for (int i=0; i < 3; i++) { dircomm->write("."); while (dircomm->read() > 0) { + Pmsg2(000, "begin new command loop %i %s\n", i, m_dir->name()); if (mainWin->m_displayAll) display_text(dircomm->msg()); } if (dircomm->m_at_main_prompt) { @@ -566,7 +575,7 @@ void Console::displayToPrompt(int conn) int stat = 0; QString buf; - if (mainWin->m_commDebug) Pmsg0(000, "DisplaytoPrompt\n"); + if (mainWin->m_commDebug) Pmsg1(000, "DisplaytoPrompt %s\n", m_dir->name()); while (!dircomm->m_at_prompt) { if ((stat=dircomm->read()) > 0) { buf += dircomm->msg(); @@ -578,7 +587,7 @@ void Console::displayToPrompt(int conn) } } display_text(buf); - if (mainWin->m_commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat); + if (mainWin->m_commDebug) Pmsg2(000, "endDisplaytoPrompt=%d %s\n", stat, m_dir->name()); } void Console::discardToPrompt(int conn) @@ -586,7 +595,7 @@ void Console::discardToPrompt(int conn) DirComm *dircomm = m_dircommHash.value(conn); int stat = 0; - if (mainWin->m_commDebug) Pmsg0(000, "discardToPrompt\n"); + if (mainWin->m_commDebug) Pmsg1(000, "discardToPrompt %s\n", m_dir->name()); if (mainWin->m_displayAll) { displayToPrompt(conn); } else { @@ -594,7 +603,7 @@ void Console::discardToPrompt(int conn) stat=dircomm->read(); } } - if (mainWin->m_commDebug) Pmsg1(000, "endDiscardToPrompt=%d\n", stat); + if (mainWin->m_commDebug) Pmsg2(000, "endDiscardToPrompt=%d %s\n", stat, m_dir->name()); } /* @@ -780,14 +789,15 @@ bool Console::newDirComm(int &conn) m_dircommCounter += 1; conn = m_dircommCounter; if (mainWin->m_connDebug) - Pmsg1(000, "DirComm %i About to Create and Connect\n", m_dircommCounter); + Pmsg2(000, "DirComm %i About to Create and Connect %s\n", m_dircommCounter, m_dir->name()); DirComm *dircomm = new DirComm(this, m_dircommCounter); m_dircommHash.insert(m_dircommCounter, dircomm); bool success = dircomm->connect_dir(); - if (mainWin->m_connDebug) + if (mainWin->m_connDebug) { if (success) - Pmsg1(000, "DirComm %i Connected\n", conn); + Pmsg2(000, "DirComm %i Connected %s\n", conn, m_dir->name()); else - Pmsg1(000, "DirComm %i NOT Connected\n", conn); + Pmsg2(000, "DirComm %i NOT Connected %s\n", conn, m_dir->name()); + } return success; } diff --git a/bacula/src/qt-console/jobs/jobs.cpp b/bacula/src/qt-console/jobs/jobs.cpp index b8e9ffb08a..843c057283 100644 --- a/bacula/src/qt-console/jobs/jobs.cpp +++ b/bacula/src/qt-console/jobs/jobs.cpp @@ -70,6 +70,7 @@ Jobs::~Jobs() void Jobs::populateTable() { m_populated = true; + mainWin->waitEnter(); Freeze frz(*tableWidget); /* disable updating*/ @@ -133,6 +134,7 @@ void Jobs::populateTable() item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); } } + mainWin->waitExit(); } /* diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 7b7125a14a..73a67f2337 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -66,7 +66,9 @@ void message_callback(int /* type */, char *msg) MainWin::MainWin(QWidget *parent) : QMainWindow(parent) { + app->setOverrideCursor(QCursor(Qt::WaitCursor)); m_isClosing = false; + m_waitState = false; m_dtformat = "yyyy-MM-dd HH:mm:ss"; mainWin = this; setupUi(this); /* Setup UI defined by main.ui (designer) */ @@ -79,9 +81,7 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) createPages(); - resetFocus(); - - connectSignals(); + resetFocus(); /* lineEdit->setFocus() */ #ifndef HAVE_QWT actionJobPlot->setEnabled(false); @@ -92,12 +92,11 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) readSettings(); - foreach(Console *console, m_consoleHash) { + foreach(Console *console, m_consoleHash) console->connect_dir(); - } m_currentConsole = (Console*)getFromHash(m_firstItem); m_currentConsole->setCurrent(); - connectConsoleSignals(); + QTimer::singleShot(2000, this, SLOT(popLists())); if (m_miscDebug) { QString directoryResourceName; m_currentConsole->getDirResName(directoryResourceName); @@ -105,6 +104,15 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) } } +void MainWin::popLists() +{ + foreach(Console *console, m_consoleHash) + console->populateLists(true); + connectConsoleSignals(); + connectSignals(); + app->restoreOverrideCursor(); +} + void MainWin::createPages() { DIRRES *dir; @@ -288,6 +296,9 @@ void MainWin::disconnectSignals() */ void MainWin::waitEnter() { + m_waitState = true; + if (mainWin->m_connDebug) + Pmsg0(000, "Entering Wait State\n"); app->setOverrideCursor(QCursor(Qt::WaitCursor)); disconnectSignals(); disconnectConsoleSignals(m_currentConsole); @@ -299,6 +310,9 @@ void MainWin::waitEnter() */ void MainWin::waitExit() { + m_waitState = false; + if (mainWin->m_connDebug) + Pmsg0(000, "Exiting Wait State\n"); app->restoreOverrideCursor(); if (m_waitTreeItem != treeWidget->currentItem()) treeWidget->setCurrentItem(m_waitTreeItem); diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 1c984e167e..330476db8d 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -60,6 +60,7 @@ public: void hashRemove(Pages *); void hashRemove(QTreeWidgetItem *, Pages *); void setMessageIcon(); + bool getWaitState() {return m_waitState; }; Console *currentConsole(); QTreeWidgetItem *currentTopItem(); Pages* getFromHash(QTreeWidgetItem *); @@ -127,6 +128,7 @@ public slots: void waitEnter(); void waitExit(); void repopLists(); + void popLists(); protected: void closeEvent(QCloseEvent *event); @@ -148,6 +150,7 @@ private: QTreeWidgetItem *m_firstItem; QTreeWidgetItem *m_waitTreeItem; bool m_isClosing; + bool m_waitState; }; #include "ui_prefs.h" diff --git a/bacula/src/qt-console/util/fmtwidgetitem.cpp b/bacula/src/qt-console/util/fmtwidgetitem.cpp index 2bc5b28ac4..f149d81cd9 100644 --- a/bacula/src/qt-console/util/fmtwidgetitem.cpp +++ b/bacula/src/qt-console/util/fmtwidgetitem.cpp @@ -69,7 +69,6 @@ QString convertJobStatus(const QString &sts) Freeze::Freeze(QWidget &q): qw(&q) { - QApplication::setOverrideCursor(Qt::WaitCursor); qw->setUpdatesEnabled(false); } @@ -77,7 +76,6 @@ Freeze::~Freeze() { if (qw) { qw->setUpdatesEnabled(true); - QApplication::restoreOverrideCursor(); qw->update(); } } -- 2.39.5