Can't make Document window visible by jassert


#1

I’m making very simple application using JUCE 1.34, I’m facing a problem. I make a window which inherit DocumentWindow. But it will stop by jassert by calling setVisible(true). Are there anything missing in my code? In Mac OS X, it works fine but the problem only happens on Windows. And when I change the base class to ResizableWindow, it works fine on Windows.

Here is my code. “CMainPain” is a component class which is built by Jucer.

[code]#include “CMainPane.h”

// CMainWindow
class CMainWindow :
// public DialogWindow
public DocumentWindow
// public ResizableWindow
{
public:
/**
Constructor.
*/
CMainWindow() :
//DialogWindow (T(“DM15Jig”), Colours::lightgrey, false)
DocumentWindow(T(“DM15Jig”), Colours::lightgrey, DocumentWindow::allButtons, true)
// ResizableWindow(T(“DM15Jig”), Colours::lightgrey, true)
{
setOpaque(true);
setContentComponent(new CMainPane);
//setMenuBar (this, commandManager);
setResizable(true, false);
centreWithSize(700, 600);

	//	don't want the window to take focus when the title-bar is clicked..
	setWantsKeyboardFocus(false);
}

/**
	Destructor
*/
virtual ~CMainWindow() { /*deleteAllChildren();*/ }

/**
	Called when the close button is pressed. Just quit the application.
*/
virtual void closeButtonPressed () { JUCEApplication::quit(); }

};[/code]

Here is a initialize function in my application.

[code] virtual void initialise(const String& commandLine)
{
static ShinyLookAndFeel mLook;
LookAndFeel::setDefaultLookAndFeel(&mLook);

	// just create the main window...
	m_pMainWindow = new CMainWindow();
	m_pMainWindow->setVisible(true);
}[/code]

Anyone please help me.

Best regards,
Masanao Hayashi


#2

I had a quick go with that code and it worked fine. Where is the assertion that’s failing?


#3

In juce_component.cpp, line 3107,

#if JUCE_CATCH_UNHANDLED_EXCEPTIONS catch (const std::exception& e) { currentlyFocusedComponent = 0; Desktop::getInstance().triggerFocusCallback(); Here!>> JUCEApplication::sendUnhandledException (&e, __FILE__, __LINE__); } catch (...) { currentlyFocusedComponent = 0; Desktop::getInstance().triggerFocusCallback(); JUCEApplication::sendUnhandledException (0, __FILE__, __LINE__); } #endif

When I call m_pWindow->setVisible(true); in my initialise() in application class, then the code goes this assertion point…

Best regards,
Masanao Hayashi


#4

…right - well if you’re getting an exception, turn on exception catching and you’ll be able to see what’s going wrong. Probably crashing somewhere in your CMainPane class, which I had to comment-out when I tried the code.


#5

hmm… but the component CMainPain is just saved by the latest version of Jucer, it has two labels and one text button only. And the whole code works fine on Mac OS X… hmm…

Masa


#6

Of course this could be a juce bug, but I can’t guess what’s causing the exception unless you can catch it happening.


#7

Well, I sent whole source code of that project. Please investigate it if you have time.

Thanks.

Masa


#8

I apologize… that’s my fault. I forgot to turn on the “Enable Run-Time Type Info” in the compiler settings…

Now it works fine.

Best regards,
Masanao Hayashi


#9