2013-09-07 1 views
0

제 프로젝트에서 꽤 많은 시간이 걸릴 수있는 많은 계산을하는 많은 루프가 있습니다. 로드하는 동안 오류가 발생할 때까지 모든 것이 잘 실행됩니다. 모든 것을 계산할 때, 프로그램은로드가 끝날 때까지 "Unresponsive"가됩니다.Qt 응답하지 않음 시간 초과?

Exception at 0x7585b9bc, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) in Qt5Cored!QTimer::isSingleShot 

그 응답 타이머를 비활성화 할 수있는 방법이 있나요 : 그것은 거기 타이머의 일종이며 60 초에 도달하면 디버깅을 중지하고 나는이 오류가 보인다?

감사합니다.

편집 : 여기 루프가 있습니다. 너무 추상적이어서이 루프의 전체 컨텍스트를 알지 못해 사과드립니다. ://하지만이 프로그램은 정확한 시점에서 멈추지 않는다는 것을 알고 있습니다. 때로는 i == 498, 때로는 499 등이됩니다.

for(int i=0; i<=728; i++) 
    { 
     int sections; 
     if(PCBRchunks[i] != "Null") 
     { 
      QString blockId; 
      PCBRblocks[i].fill('0', 131072); 

      //Get number of sections 
      temp_hex = PCBRchunks[i].mid(PCBRchunks[i].indexOf("09000853656374696f6e73")+30, 2); 
      HexToInt2(temp_hex, temp_int); 
      sections = temp_int; 

      int totalStart; 
      totalStart = PCBRchunks[i].indexOf("070006426c6f636b7300001000")+26; 

      for(int s=0; s<=sections-1; s++) 
      { 
       int y; 
       temp_hex = PCBRchunks[i].mid(totalStart + (s*20604) + 20574, 2); 
       HexToInt2(temp_hex, y); 

       for(int k=0; k<=255; k++) 
       { 
        for(int p=0; p<=15; p++) 
        { 
         blockId = PCBRchunks[i].mid(totalStart + (s*20604) + (p*512) + ((((k-((k/16)*16))*16)+(k/16))*2), 2); 
         if(y<8) 
          PCBRblocks[i].replace((p*2)+(k*256)+(y*32), 2, blockId); 
         else 
          PCBRblocks[i].replace((p*2)+(k*256)+((y-8)*32)+65536, 2, blockId); 
        } 
       } 
      } 
     } 

     if(PCBLchunks[i] != "Null") 
     { 
      QString blockId; 
      PCBLblocks[i].fill('0', 131072); 

      //Get number of sections 
      temp_hex = PCBLchunks[i].mid(PCBLchunks[i].indexOf("09000853656374696f6e73")+30, 2); 
      HexToInt2(temp_hex, temp_int); 
      sections = temp_int; 

      int totalStart; 
      totalStart = PCBLchunks[i].indexOf("070006426c6f636b7300001000")+26; 

      for(int s=0; s<=sections-1; s++) 
      { 
       int y; 
       temp_hex = PCBLchunks[i].mid(totalStart + (s*20604) + 20574, 2); 
       HexToInt2(temp_hex, y); 

       for(int k=0; k<=255; k++) 
       { 
        for(int p=0; p<=15; p++) 
        { 
         blockId = PCBLchunks[i].mid(totalStart + (s*20604) + (p*512) + ((((k-((k/16)*16))*16)+(k/16))*2), 2); 
         if(y<8) 
          PCBLblocks[i].replace((p*2)+(k*256)+(y*32), 2, blockId); 
         else 
          PCBLblocks[i].replace((p*2)+(k*256)+((y-8)*32)+65536, 2, blockId); 
        } 
       } 
      } 
     } 
     if(PCTRchunks[i] != "Null") 
     { 
      QString blockId; 
      PCTRblocks[i].fill('0', 131072); 

      //Get number of sections 
      temp_hex = PCTRchunks[i].mid(PCTRchunks[i].indexOf("09000853656374696f6e73")+30, 2); 
      HexToInt2(temp_hex, temp_int); 
      sections = temp_int; 

      int totalStart; 
      totalStart = PCTRchunks[i].indexOf("070006426c6f636b7300001000")+26; 

      for(int s=0; s<=sections-1; s++) 
      { 
       int y; 
       temp_hex = PCTRchunks[i].mid(totalStart + (s*20604) + 20574, 2); 
       HexToInt2(temp_hex, y); 

       for(int k=0; k<=255; k++) 
       { 
        for(int p=0; p<=15; p++) 
        { 
         blockId = PCTRchunks[i].mid(totalStart + (s*20604) + (p*512) + ((((k-((k/16)*16))*16)+(k/16))*2), 2); 
         if(y<8) 
          PCTRblocks[i].replace((p*2)+(k*256)+(y*32), 2, blockId); 
         else 
          PCTRblocks[i].replace((p*2)+(k*256)+((y-8)*32)+65536, 2, blockId); 
        } 
       } 
      } 
     } 
     if(PCTLchunks[i] != "Null") 
     { 
      QString blockId; 
      PCTLblocks[i].fill('0', 131072); 

      //Get number of sections 
      temp_hex = PCTLchunks[i].mid(PCTLchunks[i].indexOf("09000853656374696f6e73")+30, 2); 
      HexToInt2(temp_hex, temp_int); 
      sections = temp_int; 

      int totalStart; 
      totalStart = PCTLchunks[i].indexOf("070006426c6f636b7300001000")+26; 

      for(int s=0; s<=sections-1; s++) 
      { 
       int y; 
       temp_hex = PCTLchunks[i].mid(totalStart + (s*20604) + 20574, 2); 
       HexToInt2(temp_hex, y); 

       for(int k=0; k<=255; k++) 
       { 
        for(int p=0; p<=15; p++) 
        { 
         blockId = PCTLchunks[i].mid(totalStart + (s*20604) + (p*512) + ((((k-((k/16)*16))*16)+(k/16))*2), 2); 
         if(y<8) 
          PCTLblocks[i].replace((p*2)+(k*256)+(y*32), 2, blockId); 
         else 
          PCTLblocks[i].replace((p*2)+(k*256)+((y-8)*32)+65536, 2, blockId); 
        } 
       } 
      } 
     } 
     qDebug() << i; 
     ui->progressBar->setValue((i*100)/729); 
    } 

답변

2

나는 그것이 Qt 내에 있지 않다고 생각합니다. 그것은 운영 체제에 있습니다. 가장 좋은 해결책은 작업자 스레드에서 작업을 수행하여 UI 스레드가 그 동안 메시지를 처리 ​​할 수 ​​있도록하는 것입니다.

1

무거운 계산을 위해 작업자 스레드를 설정하여 UI가 응답하지 않도록하는 것이 일반적입니다. 그 이유 때문에 작업자 스레드는 주 UI 스레드에서 분리됩니다. 여기

당신이 std::thread를 사용할 수에도 불구하고 당신이 어떻게 일반적으로 스레드 클래스를 생성하는 아주 자세한 설명과 예제와 함께 기사를 찾을 수 있습니다 C++ 11 : 여기

http://www.codeproject.com/Articles/21114/Creating-a-C-Thread-Class

찾을 수 있습니다 아주 자세한 설명과 작업자 스레드를 생성하는 방법을 예제와 함께 기사 :

http://www.codeproject.com/Articles/552/Using-Worker-Threads

희망, 그것은 도움이됩니다.

+0

그래서 내 루프를 스레드에서 얻었고 모든 것이 연결되었지만 메인 프로그램의 변수를 스레드로 전달하는 방법에 대한 단서가 없습니다. 내 주 프로그램에서 cThread.start();를 사용하여 스레드를 시작합니다. 자동으로 run() 함수가 시작됩니다. 스레드와 변수를주고받는 방법은 무엇입니까? – mrg95

+0

mc360pro : 나는 그 질문을 이해하지 못한다. 스레드와 변수를 보내지 않습니다. – lpapp

+0

? 그렇다면 내 스레드는 무엇을 할 것인가? 나는 스레드가 단지 내가 필요로하는 것을 수행하여 별도로 수행 한 다음 "변경된"변수를 리턴한다고 생각했습니다. – mrg95

관련 문제