Bug 299526 - Create empty settings object if none is created from outside okular core library
Summary: Create empty settings object if none is created from outside okular core library
Status: RESOLVED NOT A BUG
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 0.14.80
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-06 20:27 UTC by Bogdan Cristea
Modified: 2012-10-31 16:05 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
create empty settings object if none is created from outside okular core library (866 bytes, patch)
2012-05-06 20:30 UTC, Bogdan Cristea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bogdan Cristea 2012-05-06 20:27:29 UTC
A better separation is needed between okular core library and the front-end. Currently one Settings object is initialized from part.cpp, which is not in okular core library. Also, settings.h file is not exposed to the user (at least not in openSUSE 21.1 okular devel package) and thus it makes impossible to use okular core library only.

Reproducible: Always

Steps to Reproduce:
1. Use okular core library in a stand alone program (not okular front end)
2. Try to open a document
Actual Results:  
The program exists immediately saying that Settings object has not been initialized

Expected Results:  
Should be able to use Okular core library using the exposed header files.

This issue could be fixed by calling Settings::instance("") in DocumentPrivate ctor. See the patch below:


From a24c05938c3097d4d821dd71db5f7e49ea34855a Mon Sep 17 00:00:00 2001
From: Bogdan Cristea <cristeab@gmail.com>
Date: Sun, 6 May 2012 22:11:25 +0200
Subject: [PATCH] create empty settings object if none is created from outside
 okular core library

---
 core/document_p.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/core/document_p.h b/core/document_p.h
index 4f78d9a..c3bcd66 100644
--- a/core/document_p.h
+++ b/core/document_p.h
@@ -26,6 +26,7 @@
 // local includes
 #include "fontinfo.h"
 #include "generator.h"
+#include "settings.h"
 
 class QEventLoop;
 class QTimer;
@@ -87,6 +88,7 @@ class DocumentPrivate
             m_fontsCached( false ),
             m_documentInfo( 0 )
         {
+	    Settings::instance("");//make sure that Settings object is initialized
             calculateMaxTextPages();
         }
 
-- 
1.7.7
Comment 1 Bogdan Cristea 2012-05-06 20:30:48 UTC
Created attachment 70906 [details]
create empty settings object if none is created from outside  okular core library
Comment 2 Albert Astals Cid 2012-05-07 00:28:52 UTC
That's a quick and dirty solution but not really optimal since you have no access to the settings headers so you are stuck with the default options that might not suit you.
The solution I would like is make it so that the user of the library can create it's own settings instance, the problem is that settings now mixes things used in core like the memory and things used in the ui like should show the sidebar or not.

What do you think about splitting the current settings into CoreSettings and UISettings and then installing the CoreSettings headers?
Comment 3 Bogdan Cristea 2012-05-07 08:22:39 UTC
That could be even better. Maybe we could create some documentation about the available settings.
Comment 4 Albert Astals Cid 2012-05-07 16:41:48 UTC
They are documented in okular/conf/okular.kcfg