Pārlūkot izejas kodu

Fix lockup while creating new file or opening file. Other SET_TEXT_SAFE calls still crash though, calling setText with a view open doesn't work anymore.

Fix crash while opening project (another instance of emptyQString[0]).


git-svn-id: file:///var/svn/tigccpp/trunk@1021 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 17 gadi atpakaļ
vecāks
revīzija
8d19b9e055
2 mainītis faili ar 7 papildinājumiem un 7 dzēšanām
  1. 4 4
      ktigcc/mainform.cpp
  2. 3 3
      ktigcc/srcfilewin.cpp

+ 4 - 4
ktigcc/mainform.cpp

@@ -1768,6 +1768,9 @@ void *MainForm::createView(const QString &fileName, const QString &fileText, Q3L
   doc->setModified(FALSE);
   if (doc->openStream("text/plain",fileName))
     doc->closeStream();
+  // Set text.
+  SET_TEXT_SAFE(doc,fileText);
+  doc->setModified(FALSE);
   // Create View object.
   KTextEditor::View *newView = (KTextEditor::View *) doc->createView(widgetStack);
   newView->hide();
@@ -1807,9 +1810,6 @@ void *MainForm::createView(const QString &fileName, const QString &fileText, Q3L
   connect(newView->document(),SIGNAL(selectionChanged()),this,SLOT(current_view_selectionChanged()));
   connect(newView->document(),SIGNAL(charactersInteractivelyInserted(int,int,const QString&)),this,SLOT(current_view_charactersInteractivelyInserted(int,int,const QString&)));
   newView->setContextMenu(te_popup);
-  // Set text.
-  SET_TEXT_SAFE(newView->document(),fileText);
-  newView->document()->setModified(FALSE);
 // FIXME
 //  newView->document()->clearUndo();
 //  newView->document()->clearRedo();
@@ -1949,7 +1949,7 @@ void MainForm::fileOpen_addList(Q3ListViewItem *category,void *fileListV,void *d
     if (pslash>=0) caption.remove(0,pslash+1);
     treePath=fileList->folder[i].trimmed();
     //check for a backslash at the end and remove it if it's there.
-    if (treePath[treePath.length()-1]=='\\')
+    if (!treePath.isEmpty() && treePath[treePath.length()-1]=='\\')
       treePath.truncate(treePath.length()-1);
     parent=category;
     if (!treePath.isEmpty())

+ 3 - 3
ktigcc/srcfilewin.cpp

@@ -430,6 +430,9 @@ void *SourceFileWindow::createView(const QString &fileName, const QString &fileT
   doc->setModified(FALSE);
   if (doc->openStream("text/plain",fileName))
     doc->closeStream();
+  // Set text.
+  SET_TEXT_SAFE(doc,fileText);
+  doc->setModified(FALSE);
   // Create View object.
   KTextEditor::View *newView = (KTextEditor::View *) doc->createView(centralWidget());
   newView->hide();
@@ -456,9 +459,6 @@ void *SourceFileWindow::createView(const QString &fileName, const QString &fileT
   connect(newView->document(),SIGNAL(selectionChanged()),this,SLOT(current_view_selectionChanged()));
   connect(newView->document(),SIGNAL(charactersInteractivelyInserted(int,int,const QString&)),this,SLOT(current_view_charactersInteractivelyInserted(int,int,const QString&)));
   newView->setContextMenu(THIS->te_popup);
-  // Set text.
-  SET_TEXT_SAFE(newView->document(),fileText);
-  newView->document()->setModified(FALSE);
 // FIXME
 //  newView->document()->clearUndo();
 //  newView->document()->clearRedo();