Changeset 122
- Timestamp:
- 04/26/06 16:32:51 (2 years ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
src/IDocument.cxx (modified) (12 diffs)
-
src/MainPter.cxx (modified) (1 diff)
-
tests/DumbDocument.cxx (modified) (1 diff)
-
tests/MainPterTest.cxx (modified) (25 diffs)
-
tests/PDFDocumentTest.cxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/IDocument.cxx
r121 r122 17 17 18 18 #include <config.h> 19 #include <string.h> 19 20 #include "epdfview.h" 20 21 … … 143 144 PageRequest *request = (PageRequest *)g_async_queue_pop (renderQueue); 144 145 G_LOCK (rendering); 145 if ( 0 < request->pageNum ) 146 { 147 if ( NULL != request->document ) 148 { 149 request->page = request->document->renderPage (request->pageNum); 150 } 151 request->done = TRUE; 152 } 153 else if ( -1 == request->pageNum ) 146 if ( -1 == request->pageNum ) 154 147 { 155 148 delete request; … … 158 151 else 159 152 { 153 if ( 0 < request->pageNum ) 154 { 155 request->page = 156 request->document->renderPage (request->pageNum); 157 } 160 158 request->done = TRUE; 161 159 } … … 215 213 // thread that we are done. 216 214 PageRequest *request = new PageRequest; 215 memset (request, 0, sizeof (PageRequest)); 217 216 request->pageNum = -1; 218 217 g_async_queue_unref (m_RenderQueue); … … 680 679 IDocument::getCurrentPage () 681 680 { 682 GList *cache = g_list_first (m_PageCache);683 681 PageRequest *request = NULL; 684 while ( NULL != cache && NULL == request ) 682 for ( GList *cache = g_list_first (m_PageCache) ; 683 NULL != cache && NULL == request ; 684 cache = g_list_next (cache) ) 685 685 { 686 686 PageRequest *tmpRequest = (PageRequest *)cache->data; … … 689 689 request = tmpRequest; 690 690 } 691 cache = g_list_next (cache);692 691 } 693 692 694 693 if ( NULL == request ) 694 { 695 695 return NULL; 696 696 } 697 697 WAIT_REQUEST (request); 698 699 698 return request->page; 700 699 } … … 1003 1002 // Check if the page is already on cache. 1004 1003 PageRequest *request = NULL; 1005 GList *cache = g_list_first (m_PageCache); 1006 while ( NULL != cache && NULL == request) 1004 for ( GList *cache = g_list_first (m_PageCache) ; 1005 NULL != cache && NULL == request ; 1006 cache = g_list_next (cache) ) 1007 1007 { 1008 1008 PageRequest *tmpRequest = (PageRequest *)cache->data; … … 1011 1011 request = tmpRequest; 1012 1012 } 1013 cache = g_list_next (cache);1014 1013 } 1015 1014 … … 1030 1029 PageRequest *oldestRequest = NULL; 1031 1030 guint32 oldestAge = G_MAXUINT32; 1032 for ( cache = g_list_first (m_PageCache) ; NULL != cache ;1031 for ( GList *cache = g_list_first (m_PageCache) ; NULL != cache ; 1033 1032 cache = g_list_next (cache) ) 1034 1033 { … … 1040 1039 } 1041 1040 } 1042 m_PageCache = g_list_remove (m_PageCache, oldestRequest);1041 m_PageCache = g_list_remove_all (m_PageCache, oldestRequest); 1043 1042 WAIT_REQUEST (oldestRequest); 1044 1043 delete oldestRequest->page; 1044 oldestRequest->page = NULL; 1045 1045 delete oldestRequest; 1046 1046 } … … 1096 1096 { 1097 1097 PageRequest *request = (PageRequest *)cache->data; 1098 request-> document = NULL;1098 request->pageNum = 0; 1099 1099 } 1100 1100 G_UNLOCK (rendering); … … 1107 1107 WAIT_REQUEST (request); 1108 1108 delete request->page; 1109 request->page = NULL; 1109 1110 delete request; 1110 1111 } -
trunk/src/MainPter.cxx
r120 r122 613 613 GError **error) 614 614 { 615 g_assert ( NULL != m_Document && "The document is NULL."); 616 615 617 // if fileName is NULL, then the user cancelled the operation. 616 618 // I don't need to do anything in this case. I'm only interested when -
trunk/tests/DumbDocument.cxx
r120 r122 36 36 DumbDocument::~DumbDocument () 37 37 { 38 clearCache (); 38 39 g_free (m_TestPassword); 39 40 } -
trunk/tests/MainPterTest.cxx
r120 r122 26 26 CPPUNIT_TEST_SUITE_REGISTRATION (MainPterTest); 27 27 28 // Constants. 29 static const gint SLEEP_TIME = 250000; 30 28 31 /// 29 32 /// @brief Sets up the environment for each test. … … 100 103 m_MainPter->openFileActivated (); 101 104 // Sleep to let the thread open the file. 102 usleep ( 500);105 usleep (SLEEP_TIME); 103 106 CPPUNIT_ASSERT_EQUAL (0, 104 107 g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); … … 122 125 m_MainPter->openFileActivated (); 123 126 // Sleep to let the thread open the file. 124 usleep ( 500);127 usleep (SLEEP_TIME); 125 128 CPPUNIT_ASSERT_EQUAL (0, 126 129 g_ascii_strcasecmp ("Test PDF", m_View->getTitle ())); … … 153 156 m_MainPter->openFileActivated (); 154 157 // Sleep to let the thread open the file. 155 usleep ( 500);158 usleep (SLEEP_TIME); 156 159 CPPUNIT_ASSERT_EQUAL (0, 157 160 g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); … … 186 189 m_MainPter->openFileActivated (); 187 190 // Sleep to let the thread open the file. 188 usleep ( 500);191 usleep (SLEEP_TIME); 189 192 CPPUNIT_ASSERT_EQUAL (0, 190 193 g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); … … 221 224 m_MainPter->openFileActivated (); 222 225 // Sleep to let the thread open the file. 223 usleep ( 500);226 usleep (SLEEP_TIME); 224 227 CPPUNIT_ASSERT_EQUAL (0, 225 228 g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); … … 256 259 m_MainPter->openFileActivated (); 257 260 // Sleep to let the thread open the file. 258 usleep ( 500);261 usleep (SLEEP_TIME); 259 262 CPPUNIT_ASSERT_EQUAL (0, 260 263 g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); … … 291 294 m_MainPter->openFileActivated (); 292 295 // Sleep to let the thread open the file. 293 usleep ( 500);296 usleep (SLEEP_TIME); 294 297 CPPUNIT_ASSERT_EQUAL (0, 295 298 g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); … … 324 327 m_MainPter->openFileActivated (); 325 328 // Sleep to let the thread open the file. 326 usleep ( 500);329 usleep (SLEEP_TIME); 327 330 CPPUNIT_ASSERT (NULL == m_View->getLastOpenFileFolder ()); 328 331 … … 331 334 m_MainPter->openFileActivated (); 332 335 // Sleep to let the thread open the file. 333 usleep ( 500);336 usleep (SLEEP_TIME); 334 337 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("/tmp", 335 338 m_View->getLastOpenFileFolder ())); … … 337 340 m_MainPter->openFileActivated (); 338 341 // Sleep to let the thread open the file. 339 usleep ( 500);342 usleep (SLEEP_TIME); 340 343 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("/usr", 341 344 m_View->getLastOpenFileFolder ())); … … 355 358 m_MainPter->openFileActivated (); 356 359 // Sleep to let the thread open the file. 357 usleep ( 500);360 usleep (SLEEP_TIME); 358 361 // Check that sets the correct number of pages and the current page. 359 362 CPPUNIT_ASSERT_EQUAL (4, m_View->getTotalPages ()); … … 437 440 m_MainPter->openFileActivated (); 438 441 // Sleep to let the thread open the file. 439 usleep ( 500);442 usleep (SLEEP_TIME); 440 443 // Check that sets the correct number of pages and the current page. 441 444 CPPUNIT_ASSERT_EQUAL (4, m_View->getTotalPages ()); … … 518 521 m_MainPter->openFileActivated (); 519 522 // Sleep to let the thread open the file. 520 usleep ( 500);523 usleep (SLEEP_TIME); 521 524 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 522 525 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); … … 548 551 m_MainPter->openFileActivated (); 549 552 // Sleep to let the thread open the file. 550 usleep ( 500);553 usleep (SLEEP_TIME); 551 554 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 552 555 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); … … 589 592 m_MainPter->openFileActivated (); 590 593 // Sleep to let the thread open the file. 591 usleep ( 500);594 usleep (SLEEP_TIME); 592 595 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 593 596 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, m_Document->getZoom (), 0.0001); … … 655 658 m_MainPter->openFileActivated (); 656 659 // Sleep to let the thread open the file. 657 usleep ( 500);660 usleep (SLEEP_TIME); 658 661 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 659 662 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, m_Document->getZoom (), 0.0001); … … 720 723 m_MainPter->openFileActivated (); 721 724 // Sleep to let the thread open the file. 722 usleep ( 500);725 usleep (SLEEP_TIME); 723 726 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 724 727 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, m_Document->getZoom (), 0.0001); … … 765 768 m_MainPter->openFileActivated (); 766 769 // Sleep to let the thread open the file. 767 usleep ( 500);770 usleep (SLEEP_TIME); 768 771 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 769 772 … … 779 782 m_MainPter->reloadActivated (); 780 783 // Sleep to let the thread open the file. 781 usleep ( 500);784 usleep (SLEEP_TIME); 782 785 CPPUNIT_ASSERT_EQUAL (0, 783 786 g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); … … 803 806 m_MainPter->openFileActivated (); 804 807 // Sleep to let the thread open the file. 805 usleep ( 500);808 usleep (SLEEP_TIME); 806 809 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 807 810 CPPUNIT_ASSERT_EQUAL (0, … … 822 825 m_MainPter->reloadActivated (); 823 826 // Sleep to let the thread open the file. 824 usleep ( 500);827 usleep (SLEEP_TIME); 825 828 CPPUNIT_ASSERT_EQUAL (0, 826 829 g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); … … 847 850 m_MainPter->openFileActivated (); 848 851 // Sleep to let the thread open the file. 849 usleep ( 500);852 usleep (SLEEP_TIME); 850 853 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 851 854 CPPUNIT_ASSERT_EQUAL (0, … … 868 871 m_MainPter->reloadActivated (); 869 872 // Sleep to let the thread open the file. 870 usleep ( 500);873 usleep (SLEEP_TIME); 871 874 CPPUNIT_ASSERT_EQUAL (0, 872 875 g_ascii_strcasecmp("newpassword", m_Document->getPassword ())); … … 907 910 m_MainPter->openFileActivated (); 908 911 // Sleep to let the thread open the file. 909 usleep ( 500);912 usleep (SLEEP_TIME); 910 913 CPPUNIT_ASSERT (m_View->isShownSidebar ()); 911 914 CPPUNIT_ASSERT (outline == m_View->getOutline ()); -
trunk/tests/PDFDocumentTest.cxx
r120 r122 507 507 CPPUNIT_ASSERT (0 != memcmp (testData, page->getData (), imageSize)); 508 508 delete[] testData; 509 delete page; 510 511 g_free (testFile); 512 } 509 510 g_free (testFile); 511 }
