diff options
author | deva <deva> | 2008-06-02 13:03:33 +0000 |
---|---|---|
committer | deva <deva> | 2008-06-02 13:03:33 +0000 |
commit | 322a83c48618b2f58e1014daff6f3956af8070ea (patch) | |
tree | aa6124cd9f13ee2308e28d33175dc31eb1d34984 /client/macro.cc | |
parent | f9f04013fca46fa256664bbf1f983c966f253400 (diff) |
A large number of small changes in widgets, primarily validation oriented.
Diffstat (limited to 'client/macro.cc')
-rw-r--r-- | client/macro.cc | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/client/macro.cc b/client/macro.cc index 82c68a4..d4ae0c0 100644 --- a/client/macro.cc +++ b/client/macro.cc @@ -25,13 +25,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "macro.h" -#include "builder.h" #include "sendrecieve.h" #include <QDomDocument> #include <QApplication> #define MACRO_EVENT_ID 65432 +QLinkedList< MacroWindow * > macrowindows; + extern QString cpr; extern QString user; extern QString host; @@ -117,11 +118,14 @@ static void create_macro(QString course, QString macro) if (!xml_doc.setContent(ba)) { printf("ERROR: Invalid XML recieved!\n"); fwrite(ba.data(), ba.size(), 1, stdout); + return; } - // Initiate the macro builder with the xml document - // FIXME: This should be done in some other way, to prevent the memory leak. - new Builder(&xml_doc); + cleanup_macros(); + + // Initiate the new macro window with the xml document and push + // it to the window list + macrowindows.push_back( new MacroWindow(&xml_doc) ); } bool MacroEventFilter::eventFilter( QObject *, QEvent *e ) @@ -135,6 +139,26 @@ bool MacroEventFilter::eventFilter( QObject *, QEvent *e ) } } +// Delete all closed windows from window list +void cleanup_macros() +{ + int dead = 0; + int live = 0; + + QLinkedList< MacroWindow * >::iterator i = macrowindows.begin(); + while(i != macrowindows.end()) { + if( (*i)->isClosed() ) { + dead++; + delete *i; + i = macrowindows.erase(i); + } else { + live++; + i++; + } + } + printf("Found %d live ones and %d dead ones.\n", live, dead); +} + void new_macro(QString course, QString macro) { if(macro_event_filter == NULL) { |