Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-19 Thread Juergen Spitzmueller
Georg Baum wrote:
 Here comes the long promised patch as discussed with Jean-Marc and Jürgen.
 Jürgen, if that is OK with you I'll commit it.

Yes, please.

Jürgen


Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-19 Thread Georg Baum
Am Donnerstag, 18. Mai 2006 23:01 schrieb Jean-Marc Lasgouttes:
  Georg == Georg Baum [EMAIL PROTECTED] writes:
 
 Georg Here comes the long promised patch as discussed with Jean-Marc
 Georg and Jürgen. Jürgen, if that is OK with you I'll commit it.
 
 And if Jürgen is OK with it, it is OK for 1.4 too.

It is in now. I did not change status.14x because this should be 
conssidered as part of the natbib speedup patch.


Georg



Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-19 Thread Jean-Marc Lasgouttes
 Georg == Georg Baum [EMAIL PROTECTED] writes:

Georg It is in now. I did not change status.14x because this should
Georg be conssidered as part of the natbib speedup patch.

Very good.

JMarc


Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-19 Thread Juergen Spitzmueller
Georg Baum wrote:
> Here comes the long promised patch as discussed with Jean-Marc and Jürgen.
> Jürgen, if that is OK with you I'll commit it.

Yes, please.

Jürgen


Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-19 Thread Georg Baum
Am Donnerstag, 18. Mai 2006 23:01 schrieb Jean-Marc Lasgouttes:
> > "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:
> 
> Georg> Here comes the long promised patch as discussed with Jean-Marc
> Georg> and Jürgen. Jürgen, if that is OK with you I'll commit it.
> 
> And if Jürgen is OK with it, it is OK for 1.4 too.

It is in now. I did not change status.14x because this should be 
conssidered as part of the natbib speedup patch.


Georg



Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-19 Thread Jean-Marc Lasgouttes
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

Georg> It is in now. I did not change status.14x because this should
Georg> be conssidered as part of the natbib speedup patch.

Very good.

JMarc


[patch] prevent automatic loading of child documents for natbib labels

2006-05-18 Thread Georg Baum
Here comes the long promised patch as discussed with Jean-Marc and Jürgen. 
Jürgen, if that is OK with you I'll commit it.


Georg

Log:
Prevent automatic opening of child docs because of natbib labels
* src/insets/insetinclude.h
(updateBibfilesCache): adjust comment
(getBibfilesCache): ditto

* src/insets/insetinclude.C
(getChildBuffer): new, return the buffer of the child if it exists
(updateBibfilesCache): update the child buffer only if already loaded
(getBibfilesCache): scan the child buffer only if already loaded

* src/buffer.h
(updateBibfilesCache): adjust comment
(getBibfilesCache): ditto
(bibfilesCache_): ditto
Index: src/insets/insetinclude.h
===
--- src/insets/insetinclude.h	(Revision 13865)
+++ src/insets/insetinclude.h	(Arbeitskopie)
@@ -56,11 +56,14 @@ public:
 		std::vectorstd::pairstd::string,std::string   keys) const;
 	/** Update the cache with all bibfiles in use of the child buffer
 	 *  (including bibfiles of grandchild documents).
+	 *  Does nothing if the child document is not loaded to prevent
+	 *  automatic loading of all child documents upon loading the master.
 	 *  \param buffer the Buffer containing this inset.
 	 */
 	void updateBibfilesCache(Buffer const  buffer);
 	/** Return the cache with all bibfiles in use of the child buffer
 	 *  (including bibfiles of grandchild documents).
+	 *  Return an empty vector if the child doc is not loaded.
 	 *  \param buffer the Buffer containing this inset.
 	 */
 	std::vectorstd::string const 
Index: src/insets/insetinclude.C
===
--- src/insets/insetinclude.C	(Revision 13865)
+++ src/insets/insetinclude.C	(Arbeitskopie)
@@ -301,6 +301,20 @@ string const InsetInclude::getScreenLabe
 
 namespace {
 
+/// return the child buffer if the file is a LyX doc and is loaded
+Buffer * getChildBuffer(Buffer const  buffer, InsetCommandParams const  params)
+{
+	if (isVerbatim(params))
+		return 0;
+
+	string const included_file = includedFilename(buffer, params);
+	if (!isLyXFilename(included_file))
+		return 0;
+
+	return bufferlist.getBuffer(included_file);
+}
+
+
 /// return true if the file is or got loaded.
 bool loadIfNeeded(Buffer const  buffer, InsetCommandParams const  params)
 {
@@ -616,9 +630,8 @@ void InsetInclude::fillWithBibKeys(Buffe
 
 void InsetInclude::updateBibfilesCache(Buffer const  buffer)
 {
-	if (loadIfNeeded(buffer, params_)) {
-		string const included_file = includedFilename(buffer, params_);
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+	Buffer * const tmp = getChildBuffer(buffer, params_);
+	if (tmp) {
 		tmp-setParentName();
 		tmp-updateBibfilesCache();
 		tmp-setParentName(parentFilename(buffer));
@@ -629,9 +642,8 @@ void InsetInclude::updateBibfilesCache(B
 std::vectorstring const 
 InsetInclude::getBibfilesCache(Buffer const  buffer) const
 {
-	if (loadIfNeeded(buffer, params_)) {
-		string const included_file = includedFilename(buffer, params_);
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+	Buffer * const tmp = getChildBuffer(buffer, params_);
+	if (tmp) {
 		tmp-setParentName();
 		std::vectorstring const  cache = tmp-getBibfilesCache();
 		tmp-setParentName(parentFilename(buffer));
Index: src/buffer.h
===
--- src/buffer.h	(Revision 13865)
+++ src/buffer.h	(Arbeitskopie)
@@ -255,10 +255,10 @@ public:
 	/// return all bibkeys from buffer and its childs
 	void fillWithBibKeys(std::vectorstd::pairstd::string, std::string   keys) const;
 	/// Update the cache with all bibfiles in use (including bibfiles
-	/// of child documents).
+	/// of loaded child documents).
 	void updateBibfilesCache();
 	/// Return the cache with all bibfiles in use (including bibfiles
-	/// of child documents).
+	/// of loaded child documents).
 	std::vectorstd::string const  getBibfilesCache() const;
 	///
 	void getLabelList(std::vectorstd::string ) const;
@@ -365,8 +365,8 @@ private:
 	/// it's BufferView, this should be FIXED in future.
 	StableDocIterator cursor_;
 	StableDocIterator anchor_;
-	/// A cache for the bibfiles (including bibfiles of child documents),
-	/// needed for appropriate update of natbib labels.
+	/// A cache for the bibfiles (including bibfiles of loaded child
+	/// documents), needed for appropriate update of natbib labels.
 	std::vectorstd::string bibfilesCache_;
 };
 


Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-18 Thread Jean-Marc Lasgouttes
 Georg == Georg Baum [EMAIL PROTECTED] writes:

Georg Here comes the long promised patch as discussed with Jean-Marc
Georg and Jürgen. Jürgen, if that is OK with you I'll commit it.

And if Jürgen is OK with it, it is OK for 1.4 too.

JMarc



[patch] prevent automatic loading of child documents for natbib labels

2006-05-18 Thread Georg Baum
Here comes the long promised patch as discussed with Jean-Marc and Jürgen. 
Jürgen, if that is OK with you I'll commit it.


Georg

Log:
Prevent automatic opening of child docs because of natbib labels
* src/insets/insetinclude.h
(updateBibfilesCache): adjust comment
(getBibfilesCache): ditto

* src/insets/insetinclude.C
(getChildBuffer): new, return the buffer of the child if it exists
(updateBibfilesCache): update the child buffer only if already loaded
(getBibfilesCache): scan the child buffer only if already loaded

* src/buffer.h
(updateBibfilesCache): adjust comment
(getBibfilesCache): ditto
(bibfilesCache_): ditto
Index: src/insets/insetinclude.h
===
--- src/insets/insetinclude.h	(Revision 13865)
+++ src/insets/insetinclude.h	(Arbeitskopie)
@@ -56,11 +56,14 @@ public:
 		std::vector > & keys) const;
 	/** Update the cache with all bibfiles in use of the child buffer
 	 *  (including bibfiles of grandchild documents).
+	 *  Does nothing if the child document is not loaded to prevent
+	 *  automatic loading of all child documents upon loading the master.
 	 *  \param buffer the Buffer containing this inset.
 	 */
 	void updateBibfilesCache(Buffer const & buffer);
 	/** Return the cache with all bibfiles in use of the child buffer
 	 *  (including bibfiles of grandchild documents).
+	 *  Return an empty vector if the child doc is not loaded.
 	 *  \param buffer the Buffer containing this inset.
 	 */
 	std::vector const &
Index: src/insets/insetinclude.C
===
--- src/insets/insetinclude.C	(Revision 13865)
+++ src/insets/insetinclude.C	(Arbeitskopie)
@@ -301,6 +301,20 @@ string const InsetInclude::getScreenLabe
 
 namespace {
 
+/// return the child buffer if the file is a LyX doc and is loaded
+Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
+{
+	if (isVerbatim(params))
+		return 0;
+
+	string const included_file = includedFilename(buffer, params);
+	if (!isLyXFilename(included_file))
+		return 0;
+
+	return bufferlist.getBuffer(included_file);
+}
+
+
 /// return true if the file is or got loaded.
 bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params)
 {
@@ -616,9 +630,8 @@ void InsetInclude::fillWithBibKeys(Buffe
 
 void InsetInclude::updateBibfilesCache(Buffer const & buffer)
 {
-	if (loadIfNeeded(buffer, params_)) {
-		string const included_file = includedFilename(buffer, params_);
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+	Buffer * const tmp = getChildBuffer(buffer, params_);
+	if (tmp) {
 		tmp->setParentName("");
 		tmp->updateBibfilesCache();
 		tmp->setParentName(parentFilename(buffer));
@@ -629,9 +642,8 @@ void InsetInclude::updateBibfilesCache(B
 std::vector const &
 InsetInclude::getBibfilesCache(Buffer const & buffer) const
 {
-	if (loadIfNeeded(buffer, params_)) {
-		string const included_file = includedFilename(buffer, params_);
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+	Buffer * const tmp = getChildBuffer(buffer, params_);
+	if (tmp) {
 		tmp->setParentName("");
 		std::vector const & cache = tmp->getBibfilesCache();
 		tmp->setParentName(parentFilename(buffer));
Index: src/buffer.h
===
--- src/buffer.h	(Revision 13865)
+++ src/buffer.h	(Arbeitskopie)
@@ -255,10 +255,10 @@ public:
 	/// return all bibkeys from buffer and its childs
 	void fillWithBibKeys(std::vector > & keys) const;
 	/// Update the cache with all bibfiles in use (including bibfiles
-	/// of child documents).
+	/// of loaded child documents).
 	void updateBibfilesCache();
 	/// Return the cache with all bibfiles in use (including bibfiles
-	/// of child documents).
+	/// of loaded child documents).
 	std::vector const & getBibfilesCache() const;
 	///
 	void getLabelList(std::vector &) const;
@@ -365,8 +365,8 @@ private:
 	/// it's BufferView, this should be FIXED in future.
 	StableDocIterator cursor_;
 	StableDocIterator anchor_;
-	/// A cache for the bibfiles (including bibfiles of child documents),
-	/// needed for appropriate update of natbib labels.
+	/// A cache for the bibfiles (including bibfiles of loaded child
+	/// documents), needed for appropriate update of natbib labels.
 	std::vector bibfilesCache_;
 };
 


Re: [patch] prevent automatic loading of child documents for natbib labels

2006-05-18 Thread Jean-Marc Lasgouttes
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

Georg> Here comes the long promised patch as discussed with Jean-Marc
Georg> and Jürgen. Jürgen, if that is OK with you I'll commit it.

And if Jürgen is OK with it, it is OK for 1.4 too.

JMarc