From kde-commits Mon Jun 30 23:26:39 2003 From: =?utf-8?q?Aaron=20J=2E=20Seigo?= Date: Mon, 30 Jun 2003 23:26:39 +0000 To: kde-commits Subject: kdeutils/kedit X-MARC-Message: https://marc.info/?l=kde-commits&m=105701571703319 CVS commit by aseigo: warn a user when they are going to open a large file (>2MB), which is something that kedit is remarkably (though expectedly) poor at doing fix session management so that it reloads a file even if it wasn't modified fixes a couple BRs. M +39 -25 kedit.cpp 1.180 --- kdeutils/kedit/kedit.cpp #1.179:1.180 @@ -28,4 +28,5 @@ #include +#include #include "ktextfiledlg.h" #include @@ -284,30 +284,32 @@ void TopLevel::readProperties(KConfig* c int line = config->readNumEntry("current_line", 0); int col = config->readNumEntry("current_column", 0); + int result = KEDIT_RETRY; - if(!filename.isEmpty() && modified){ - int result = openFile(filename, OPEN_READWRITE, url.fileEncoding()); - if (result == KEDIT_OK) + if(!filename.isEmpty()) { - m_url = url; - eframe->setModified(TRUE); - eframe->setCursorPosition(line, col); - setFileCaption(); - statusbar_slot(); + if (modified) + { + result = openFile(filename, OPEN_READWRITE, url.fileEncoding()); + } + else + { + result = openFile(filename, OPEN_READWRITE, url.fileEncoding()); } } - else{ + else + { + openURL(url, OPEN_READWRITE); + modified = false; + result = KEDIT_OK; + } - if(!filename.isEmpty()){ - int result = openFile(filename, OPEN_READWRITE, url.fileEncoding()); if (result == KEDIT_OK) { m_url = url; - eframe->setModified(false); + eframe->setModified(modified); eframe->setCursorPosition(line, col); setFileCaption(); statusbar_slot(); } - } - } } @@ -466,4 +468,18 @@ void TopLevel::file_open( void ) } + KIO::UDSEntry entry; + KIO::NetAccess::stat(url, entry); + KFileItem fileInfo(entry, url); + if (fileInfo.size() > 2097152 && // 2MB large/small enough? + KMessageBox::warningContinueCancel(this, + i18n("The file you have requested is larger than KEdit is designed for. " + "Please ensure you have enough system resources available to safely load this file, " + "or consider using a program that is designed to handle large files such as KWrite."), + i18n("Attempting To Open Large File"), + KStdGuiItem::cont(), "attemptingToOpenLargeFile") == KMessageBox::Cancel) + { + return; + } + TopLevel *toplevel; if( !m_url.isEmpty() || eframe->isModified() )