mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: fix KSycoca dummy strategy setup
the device was opened for reading only but for the version to be written it has to be opened for writing too Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4e81bcde1c
commit
70f9b2f953
3 changed files with 22 additions and 19 deletions
|
@ -44,19 +44,7 @@
|
|||
|
||||
#include "ksycocadevices_p.h"
|
||||
|
||||
/**
|
||||
* Sycoca file version number.
|
||||
* If the existing file is outdated, it will not get read
|
||||
* but instead we'll ask kded to regenerate a new one...
|
||||
*/
|
||||
#define KSYCOCA_VERSION 244
|
||||
|
||||
/**
|
||||
* Sycoca file name, used internally (by kbuildsycoca)
|
||||
*/
|
||||
#define KSYCOCA_FILENAME "ksycoca4"
|
||||
|
||||
static bool s_autoRebuild = true;
|
||||
static bool s_autoRebuild = false;
|
||||
|
||||
// The following limitations are in place:
|
||||
// Maximum length of a single string: 8192 bytes
|
||||
|
@ -165,9 +153,7 @@ bool KSycocaPrivate::openDatabase(bool openDummyIfNotFound)
|
|||
//kDebug(7011) << "No database, opening a dummy one.";
|
||||
|
||||
m_sycocaStrategy = StrategyDummyBuffer;
|
||||
QDataStream* str = stream();
|
||||
*str << qint32(KSYCOCA_VERSION);
|
||||
*str << qint32(0);
|
||||
(void)stream();
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
|
@ -184,8 +170,7 @@ KSycocaAbstractDevice* KSycocaPrivate::device()
|
|||
|
||||
KSycocaAbstractDevice* device = m_device;
|
||||
if (m_sycocaStrategy == StrategyDummyBuffer) {
|
||||
device = new KSycocaBufferDevice;
|
||||
device->device()->open(QIODevice::ReadOnly); // can't fail
|
||||
device = new KSycocaBufferDevice();
|
||||
} else {
|
||||
if (!device) {
|
||||
device = new KSycocaFileDevice(m_databasePath);
|
||||
|
@ -303,7 +288,7 @@ bool KSycocaPrivate::checkVersion()
|
|||
QDataStream *m_str = device()->stream();
|
||||
Q_ASSERT(m_str);
|
||||
m_str->device()->seek(0);
|
||||
qint32 aVersion;
|
||||
qint32 aVersion = 0;
|
||||
*m_str >> aVersion;
|
||||
if ( aVersion < KSYCOCA_VERSION ) {
|
||||
kWarning(7011) << "Found version" << aVersion << ", expecting version" << KSYCOCA_VERSION << "or higher.";
|
||||
|
|
|
@ -26,6 +26,18 @@
|
|||
#include <QFile>
|
||||
#include <QDataStream>
|
||||
|
||||
/**
|
||||
* Sycoca file version number.
|
||||
* If the existing file is outdated, it will not get read
|
||||
* but instead we'll ask kded to regenerate a new one...
|
||||
*/
|
||||
#define KSYCOCA_VERSION 244
|
||||
|
||||
/**
|
||||
* Sycoca file name, used internally (by kbuildsycoca)
|
||||
*/
|
||||
#define KSYCOCA_FILENAME "ksycoca4"
|
||||
|
||||
class KSycocaAbstractDevice;
|
||||
|
||||
class KSycocaPrivate
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#ifndef KSYCOCADEVICES_P_H
|
||||
#define KSYCOCADEVICES_P_H
|
||||
|
||||
#include "ksycoca_p.h"
|
||||
|
||||
class KSycocaAbstractDevice
|
||||
{
|
||||
public:
|
||||
|
@ -67,6 +69,10 @@ class KSycocaBufferDevice : public KSycocaAbstractDevice
|
|||
public:
|
||||
KSycocaBufferDevice() {
|
||||
m_buffer = new QBuffer();
|
||||
m_buffer->open(QIODevice::ReadWrite); // can't fail
|
||||
QDataStream str(m_buffer);
|
||||
str << qint32(KSYCOCA_VERSION);
|
||||
str << qint32(0);
|
||||
}
|
||||
~KSycocaBufferDevice() {
|
||||
delete m_buffer;
|
||||
|
|
Loading…
Add table
Reference in a new issue