From 8f80bee6c21c389f5bb724165265b16ca8322dbe Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Wed, 11 Dec 2013 23:06:15 +0800 Subject: [PATCH] Improved performance Bug #92 Large XML file without line breaks kills XML Copy Editor --- src/xmlcopyeditor.cpp | 40 +++++++++++++++++----------------------- src/xmlcopyeditor.h | 1 - 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index 784fcd6..0159048 100644 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -1661,8 +1661,8 @@ void MyFrame::OnIdle ( wxIdleEvent& event ) // check if document loaded wxString frameTitle = GetTitle(); - XmlDoc *doc; - if ( ( doc = getActiveDocument() ) == NULL ) + XmlDoc *doc = getActiveDocument(); + if ( doc == NULL ) { if ( lastDoc != NULL ) { @@ -1691,19 +1691,7 @@ void MyFrame::OnIdle ( wxIdleEvent& event ) restoreFocusToNotebook = false; } - wxString docTitle; - if ( doc->getFullFileName().empty() || !showFullPathOnFrame ) - docTitle = doc->getShortFileName(); - else - docTitle = doc->getFullFileName(); - - docTitle += _T ( " - " ); - docTitle += _ ( "XML Copy Editor" ); - - if ( frameTitle != docTitle ) - SetTitle ( docTitle ); - - // update modified field + // update modified field if ( !mainBook ) return; int index = mainBook->GetSelection(); @@ -1738,20 +1726,15 @@ void MyFrame::OnIdle ( wxIdleEvent& event ) } // update coordinates field - std::pair myControlCoordinates; int current = doc->GetCurrentPos(); - myControlCoordinates.first = doc->LineFromPosition ( current ) + 1; - myControlCoordinates.second = doc->GetColumn ( current ) + 1; - - if ( myControlCoordinates != controlCoordinates ) + if ( current != lastPos ) { wxString coordinates; coordinates.Printf ( _ ( "Ln %i Col %i" ), - myControlCoordinates.first, - myControlCoordinates.second ); + doc->LineFromPosition ( current ) + 1, + doc->GetColumn ( current ) + 1 ); GetStatusBar()->SetStatusText ( coordinates, STATUS_POSITION ); - controlCoordinates = myControlCoordinates; } // update parent element field @@ -1762,6 +1745,17 @@ void MyFrame::OnIdle ( wxIdleEvent& event ) lastPos = current; lastDoc = doc; + wxString docTitle; + if ( doc->getFullFileName().empty() || !showFullPathOnFrame ) + docTitle = doc->getShortFileName(); + else + docTitle = doc->getFullFileName(); + + docTitle += _T ( " - " ); + docTitle += _ ( "XML Copy Editor" ); + + if ( frameTitle != docTitle ) + SetTitle ( docTitle ); // don't try to find parent if pane is not shown if ( !manager.GetPane ( insertChildPanel ).IsShown() && !properties.validateAsYouType ) diff --git a/src/xmlcopyeditor.h b/src/xmlcopyeditor.h index 1aab074..47ec6b4 100644 --- a/src/xmlcopyeditor.h +++ b/src/xmlcopyeditor.h @@ -376,7 +376,6 @@ class MyFrame : public wxFrame wxString catalogPath, xslDtdPath, rssDtdPath, lzxDtdPath, xtmDtdPath, xliffDtdPath, aspellDataPath, aspellDictPath; - std::pair controlCoordinates; std::map > > promptMap; std::map validationPresetMap;