Bug 58912 - File Open gives "Could not import file of type text/x-chdr"
Summary: File Open gives "Could not import file of type text/x-chdr"
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: git master
Platform: unspecified Linux
: HI normal
Target Milestone: ---
Assignee: KDevelop Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-25 01:32 UTC by Roger Larsson
Modified: 2004-04-18 01:30 UTC (History)
0 users

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


Attachments
stdout while opening a .cpp file (2.78 KB, text/plain)
2003-05-26 23:46 UTC, Roger Larsson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Larsson 2003-05-25 01:32:08 UTC
Version:           3.0.0a4 (using KDE 3.1.9)
Compiler:          gcc version 3.2
OS:          Linux (i686) release 2.4.19-4GB

Run into something strange.

When I try to open files with kdevelop (gideon) it complains
"Could not import file of type text/x-chdr"

I am sure that it has something to do with configuration
since it works on another user account (same computer
and build).

So I have tried to remove files and restart - no help.
From what config file does the import settings come?
Comment 1 Thiago Macieira 2003-05-25 14:12:49 UTC
Sorry to be blunt, but this is a bug tracking system, not a help center. I'm closing 
this bug report. Please use the mailing lists and help forums for this. 
 
Try verifying the association between the MIME type. 
Comment 2 Roger Larsson 2003-05-26 23:46:47 UTC
Created attachment 1656 [details]
stdout while opening a .cpp file

This is what happens when I try to open a .cpp file in gideon. (Koffice?)
Everything works if I click on the same file from konqueror,
even the preview in gideon works.

And everything works on another user...
OK, I leave it as RESOLVED / INVALID for now...
Comment 3 Roger Larsson 2003-06-12 00:50:54 UTC
Tracked this down a little. 
 
kdevelop/src/partcontroller.cpp editDocument() line:236 
  // load the appropriate part factory like chosen in the editor-chooser part 
  // (Note: KTextEditor/Document is the editor in MDI mode. KTextEditor/Editor is the editor in 
SDI mode. 
  //        But KTextEditor/Editor doesn't work for the Kate part on KDE-3.0.x, so better use 
KTextEditor/Document anyway.) 
  QString services[] = {"KTextEditor/Document", "KParts/ReadWritePart", 
"KParts/ReadOnlyPart"}; 
  QString classnames[] = {"KTextEditor::Document", "KParts::ReadWritePart", 
"KParts::ReadOnlyPart"}; 
  for (uint i=0; i<3; ++i) 
  { 
    factory = findPartFactory(mimeType, services[i], preferred); 
    if (factory) 
    { 
      className = classnames[i]; 
      break; 
    } 
  } 
 
I exit from this function with i=2, "KParts/ReadOnlyPart", "KParts::ReadOnlyPart"! 
when everything works it exits with i=0, "KTextEditor/Document", "KTextEditor::Document" 
and "KTextEditor::Document" gets modified into "KTextEditor::Editor" 
 
When opening the corresponding part KateDocument is used, but for me koffice 
will be the matching plugin - koffice! (koffice can't import filter text/x-chdr...) 
 
So findPartFactory() is suspected... I have again tried to remove files to no avail... 
more later... 
 
But I wonder if it is not the MIME type rewrite a few lines up that is the real cause? 
  if (mimeType.startsWith("text/") 
      || mimeType == "application/x-zerosize" 
      || mimeType == "application/x-desktop" 
      || mimeType == "application/x-kdevelop" || mimeType == "application/x-kdevelop-project" 
      || mimeType == "image/x-xpm" 
      || mimeType == "application/x-perl") 
  { 
      mimeType = "text/plain"; 
      kapp->config()->setGroup("Editor"); 
      preferred = kapp->config()->readEntry("EmbeddedKTextEditor", ""); 
  } else if( mimeType.startsWith("inode/") ){ 
      return; 
  } 
It gets translated into text/plain before editor opens - I might have something 
wrong there - in that case the debug messages are all wrong since the part 
is opened without this MIME type info => reopen! 
Comment 4 Roger Larsson 2003-06-12 01:04:27 UTC
That was the cause! 
Changed the association for "text/plain" embedded from 
1) KHTML 
2) kword 
 
To 
1) KHTML 
2) Embedded advanced textedit (retranslated from Swedish) 
Comment 5 Roger Larsson 2003-06-17 02:09:20 UTC
Subject: Re:  File Open gives "Could not import file of type text/x-chdr"

> But I wonder if it is not the MIME type rewrite a few lines up that is the
> real cause?
> if (mimeType.startsWith("text/") 
>       || mimeType == "application/x-zerosize"
>       || mimeType == "application/x-desktop"
>       || mimeType == "application/x-kdevelop" 
>       || mimeType == "application/x-kdevelop-project"
>       || mimeType == "image/x-xpm" 
>       || mimeType == "application/x-perl")
>
>   {
>       mimeType = "text/plain";
>       kapp->config()->setGroup("Editor");
>       preferred = kapp->config()->readEntry("EmbeddedKTextEditor", "");
>   } else if( mimeType.startsWith("inode/") ){
>       return;
>   }

I tried a patch that removed the startsWith("text/") and it works much better.


But my feeling is that we get into trouble since the logical order is wrong.
Shouldn't it be more like this:

	if ( mimeType.startsWith("inode/") ) {
		return;
	}

	preferred = kapp->config()->readEntry("EmbeddedKTextEditor", "");

	if (preferred != "")
	{
		// Check all types that can be viewed as a text/* type
		if (mimeType.startsWith("text/") 
		      || mimeType == "application/x-zerosize"
		      || mimeType == "application/x-desktop"
		      || mimeType == "application/x-kdevelop"
		      || mimeType == "application/x-kdevelop-project"
		      || mimeType == "image/x-xpm" // edit as text???
		      || mimeType == "application/x-perl")
		 {
			mimeType = "text/plain";
			kapp->config()->setGroup("Editor");
		}
	}

But it might still give some unexpected error messages, but at least now
the EmbeddedTextEditor is defined...

Comment 6 Amilcar do Carmo Lucas 2003-07-15 20:03:10 UTC
This is related to: 
http://bugs.kde.org/show_bug.cgi?id=60038 
Comment 7 Jens Dagerbo 2003-12-17 08:57:01 UTC
I'm convinced our mimetype handling need improving in 3.1.. Raising priority.
Comment 8 Jens Dagerbo 2004-04-17 04:26:43 UTC
I hope KDevelop HEAD can be said to handle this in a sane way now. Every mimetype KDE has registered as "isAlso" text/plain should be opened by KDevelop, and unknown mimetypes will produce a question to the user what to do with the file in question, with the option to open as plain text. 

Closing.
Comment 9 Roger Larsson 2004-04-18 01:15:17 UTC
Looked at sources and found one possible problem (have not been able to
try it since kdevelop currently do not compile for me)

Suppose I have a specific source type that I want to open in a specific editor pluggin. Will this be possible?

I think not since the source will be text/plain and that is checked before specifics...

(I will try to remember to test this once I get kdevelop through compilation)
Comment 10 Jens Dagerbo 2004-04-18 01:30:22 UTC
>"Suppose I have a specific source type that I want to open in a specific editor pluggin."

Could you explain what you mean here? Is this theory or any actual existing case?

Btw, welcome to #kdevelop on irc.freenode.net :)