void KonqUndoManagerCommunicator::readConfig() { // We will read the configuration file *only* if we are alone, which means // only if we couldn't get the closed windows list via dbus because no // dbus instance answered/exists if(!myKonqUndoManagerCommunicatorPrivate->m_amIalone) return; // Simplification: we assume there haven't been time to open and closed // a konqueror window in 500ms of konqueror life time and thus there // shouldn't be any file in closeditem/* to do some houskeeping everytime // konqueror starts removeClosedItemsConfigFiles(); QString filename = "closeditems_saved"; QString file = KStandardDirs::locateLocal("appdata", filename); // If the config file doesn't exists, there's nothing to read if(!QFile::exists(file)) return; KConfig *config = new KConfig(filename, KConfig::SimpleConfig, "appdata"); KConfigGroup generalGroup(config, "General"); int numClosedWindows = generalGroup.readEntry("Number of Closed Windows", 0); for(int i = 0; i < numClosedWindows; i++) { // For each item, create a new ClosedWindowItem KConfigGroup configGroup(config, "Closed_Window" + QString::number(i)); QString title = configGroup.readEntry("title", i18n("no name")); int numTabs = configGroup.readEntry("numTabs", 0); KonqClosedWindowItem* closedWindowItem = new KonqClosedWindowItem( title, KonqFileUndoManager::self()->newCommandSerialNumber(), numTabs); configGroup.copyTo(&closedWindowItem->configGroup()); // TODO: the config file isn't being written to disk. Why oh why?? // I don't know. But this obviously leads to crashes if other konqueror // instance tries to read this closed window item from a non existant // config file. kDebug() << "WRITE TO DISK: " << closedWindowItem->configGroup().config()->name(); closedWindowItem->configGroup().sync(); // Add the item to all the windows and propagate over dbus addClosedWindowItem(0L, closedWindowItem, true); } delete config; }