src/file.cpp

changeset 401
89a9235b47d3
parent 400
af39fae829f6
child 402
ec95fc95e5f3
equal deleted inserted replaced
400:af39fae829f6 401:89a9235b47d3
452 f->setName (""); 452 f->setName ("");
453 f->setImplicit (false); 453 f->setImplicit (false);
454 g_loadedFiles << f; 454 g_loadedFiles << f;
455 LDOpenFile::setCurrent (f); 455 LDOpenFile::setCurrent (f);
456 456
457 if (g_loadedFiles.size() == 2) 457 LDOpenFile::closeInitialFile();
458 LDOpenFile::closeInitialFile (0);
459 458
460 g_win->R()->setFile (f); 459 g_win->R()->setFile (f);
461 g_win->fullRefresh(); 460 g_win->fullRefresh();
462 g_win->updateTitle(); 461 g_win->updateTitle();
463 f->history().updateActions(); 462 f->history().updateActions();
518 517
519 file->setImplicit (false); 518 file->setImplicit (false);
520 519
521 // If we have an anonymous, unchanged file open as the only open file 520 // If we have an anonymous, unchanged file open as the only open file
522 // (aside of the one we just opened), close it now. 521 // (aside of the one we just opened), close it now.
523 if (g_loadedFiles.size() == 2) 522 LDOpenFile::closeInitialFile();
524 LDOpenFile::closeInitialFile (0);
525 523
526 // Rebuild the object tree view now. 524 // Rebuild the object tree view now.
527 g_win->fullRefresh(); 525 g_win->fullRefresh();
528 g_win->updateTitle(); 526 g_win->updateTitle();
529 g_win->R()->setFile (file); 527 g_win->R()->setFile (file);
952 950
953 if (g_win && f) 951 if (g_win && f)
954 g_win->updateFileListItem (f); 952 g_win->updateFileListItem (f);
955 } 953 }
956 954
957 void LDOpenFile::closeInitialFile (ulong idx) { 955 // =============================================================================
958 if (g_loadedFiles.size() > idx && g_loadedFiles[idx]->name() == "" && !g_loadedFiles[idx]->hasUnsavedChanges()) 956 // This little beauty closes the initial file that was open at first when opening
959 delete g_loadedFiles[idx]; 957 // a new file over it.
960 } 958 void LDOpenFile::closeInitialFile() {
959 if (g_loadedFiles.size() == 2 &&
960 g_loadedFiles[0]->name() == "" &&
961 !g_loadedFiles[0]->hasUnsavedChanges())
962 {
963 delete g_loadedFiles[0];
964 }
965 }

mercurial